Summary of common skills of pandas

Source: Internet
Author: User

Slice:

Loc
Df.loc[num]: Select a line of DF series
DF.LOC[[NUM1,NUM2]]: Select a few lines of DF
Df.loc[[true,false,true, True]]: Select a few lines of DF

Df.loc[num,[' A ', ' C ']: Select a row of DF N column
Df.loc[[num1,num2],[' A ', ' C ']: Select a few rows of df N columns
Df.loc[[true,false,true, true],[' A ', ' C ']: Select a few rows of DF N column
#loc to mark rows with numbers, Booleans, and their lists, column names, and their list tag columns.
Df.iloc[num]: Select a line of DF series
DF.ILOC[[NUM1,NUM2]]: Select a few lines of DF
Df.iloc[[true,false,true, True]]: Select a few lines of DF

Df.iloc[num,num]: Select DF a line num column
df.iloc[[num1,num2],[2,4,5]]: Select a few rows of DF
Df.iloc[[true,false,true, True],3:5]: Select a few rows of df N columns (left closed right)
#iloc to mark rows with numbers, Booleans, and their lists, and tag columns with numbers and their lists

# #loc, Iloc The main difference is that Loc chooses certain columns to be selected only with column names, Iloc can only be selected with numbers,
Even if the column name is a number, it is no exception. Slice selection column, starting from 0, left closed right open is not included on the right.
Index rows by criteria: df[df[' a ']==0]

Vertical merge: Append need to re-assign the value to the variable, not directly change the variable like list.append ()

Df=df.append (DF2)

Summary of common skills of pandas

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.