set_index
sort_index("na_position" = "last")…………這個代碼有點小問題
ps:坐在公交車上寫總結(jié)灾锯,突然發(fā)現(xiàn)自己帶了筆記本兢榨。。顺饮。
小明思維太快吵聪,本寶寶太笨。關(guān)于索引兼雄,loc和iloc學(xué)了兩三天才理解吟逝。應(yīng)該是自己在學(xué)習(xí)的不夠?qū)W⒃斐傻摹?/p>
head( )
fial( )
fillna
下面的比較有條理
1.常用的操作
查看屬性columns,index,dtypes,shape,size
cf.shape
cf.sizw
cf.columns
方法使用head,tail,rename,replace,sort_values,describe,min,max,sum,mean,unique_values
cf.head(5)
cf.tail( )
cf.min( )
2.dataframe數(shù)據(jù)的選取添加刪除
選取
cf["height"]
cf["Player"]
cf[["player", "height","weight"]]
添加,類似字典.每次只能增加一列
cf.age = 18
條件篩選
cf["height"] >=180,返回布爾值
刪除
del? df.age
3.missing? value缺失值nan
檢測缺失值班
pd.isnull(df)
cf.fillna(0). 缺失值用0補充赦肋,填充缺失值
刪除缺失值
填充缺失值
4.文本數(shù)據(jù)
upper大寫,strip刪除空格
test.columns = test.columns.str.strip( )
split文本分割
df.Player.str.split("? ")
字符串文本索引
5索引
loc iloc
對過濾的索引块攒,因為在dataframe對數(shù)據(jù)條件篩選返回的是布爾值。
用loc金砍,主要是把布爾值轉(zhuǎn)化為文本格式局蚀。
loc是基于名稱索引,iloc是基于位置索引
回家繼續(xù)復(fù)習(xí)恕稠,今天先簡單記錄下
明日計劃
pandas學(xué)習(xí)14.15
仰臥起坐