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