Dataframe in Python by line traversal method _python

Source: Internet
Author: User
The following for you to share a dataframe in Python in accordance with the method of the line traversal, has a good reference value, I hope to be helpful to everyone. Come and see it together.

When you do a classification model, you need to follow the lines in the Dataframe to get the data for easy training and testing.

Import pandas as PDDICT=[[1,2,3,4,5,6],[2,3,4,5,6,7],[3,4,5,6,7,8],[4,5,6,7,8,9],[5,6,7,8,9,10]]DATA=PD. DataFrame (dict) print (data) for Indexs in Data.index:print (Data.loc[indexs].values[0:-1])

Experimental results:

/usr/bin/python3.4/home/ubuntu/pycharmprojects/pythonproject/findgaoxueya/test.py 0 1 2 3 4 50 1 2 3 4 5 61 2 3 4 5 6 72 3 4 5 6 7 6][3 4 5 6 7 8 94 5 6 7 8 9 10[1 2 3 4 5][2 3 4 5 4 5 6 7][4 5 6 7 8][5 6 7 8 9]process finished with exit Co De 0



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.