Analyzing the Dataframe of Panda learning notes using Python data

Source: Internet
Author: User

2 DataFrame

A: Dataframe automatically indexed by passing in a list of equal lengths

1data={' State':['Ohio','Ohio','Ohio','Nevada','Nevada'],2       ' Year':[ -,2001,2002,2001,2002],3       'Pop':[1.5,1.7,3.6,2.1,2.9]}4Frame=dataframe (data)

B: Specify sequential sequence (previously sorted by default)

1 DataFrame (data,columns=['year','State','  pop'])

C: When the data is passed in, the column does not exist, so is Nan

D: Get a series from Dataframe

1 frame2.year

E: Assign a value to modify a column

1 frame2['debt']=16.52 frame2

F: If you pass in a series when assigning, you can make exact matches, and the slots are the default values.

1 var = Series ([-1.2,-1.5,-1.7],index=[', ' four ','five'])2 frame2['  debt']=var3 frame2

G: To assign a value to a nonexistent column, a new column is created. Delete with Del

1 #为不存在的列进行赋值 then a new column is created 2 frame2['Eastern']=frame2.state=='ohio'3  frame245#删除列 6 del frame2['Eastern  ']

2 Dictionary---> Outer dictionary Key as column, inner key as row index, the key of the inner-layer dictionary is merged

1 #传入的是字典的字典 2 pop={'Nevada': {2001:2.4,2002:2.9  },3      'ohio': {:1.5,2001 :1.7,2002:3.6}}4 frame3=dataframe (POP)

A: The device--->frame3. T

B: If you set the Name property of Dataframe's index and columns these will be displayed

1 #如果设置了Dataframe的index和columns的name属性 these will be displayed. 2 frame3.index.name='year'; 3 frame3.columns.name='State'4 Frame3

C:values will return to the----with two-dimensional ndarray >frame3.values

3 Indexed Objects (cont.)

Analyzing the Dataframe of Panda learning notes using Python data

Related Article

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.