pandas的一些操作4

2021-08-21 14:31:55 字數 787 閱讀 1707

temp = [i.split(";") for i in ['租入;固定資產', '增值稅;資管;資產管理', '增值稅;貼現']]

r =

for i in temp:

r+=i

r #['租入', '固定資產', '增值稅', '資管', '資產管理', '增值稅', '貼現']

ll=['租入', '固定資產', '增值稅', '資管', '資產管理', '增值稅',' ', '貼現']

cl= [x for x in ll if x!=' ']

cl['租入', '固定資產', '增值稅', '資管', '資產管理', '增值稅', '貼現']

temp = pd.dataframe(q_count,index=['count']).t.sort_values(by='count',ascending=false)

#temp = all_data[all_data['class4'].isin(temp.index)]#[['']]

temp=pd.merge(temp.reset_index(),all_data[['class4','answer','id','clicked_num']],how='left',left_on='index',right_on='class4')

temp=temp.sort_values(['count','clicked_num'],ascending=false)

temp["id"].tolist()

pandas的一些用法

讀取以 t為分隔符的不帶volume的資料names a b c d e f g df pd.read table filename sep t names names 刪除df中某一行df.drop labels none axis 0,index none columns none level ...

pandas的一些誤區

data frame pd.dataframe data in 13 frame.iloc 6 1,asf 201 這一行會報錯indexerror single positional indexer is out of bounds in 14 frame.loc 6 1,hh 612 正確新增一...

pandas使用的一些技巧

偶然學到了一些技巧,不知道寫在哪兒,就記在這吧,持續更新ing loc是最慢的。盡量用ix代替。pandas 存在 df.iterrows 的generator 來迴圈dataframe 的 row,這樣的效率是最高的。文件丟在這 轉乙個部落格作為參考 我用的時候 for i,row in tqdm...