2016-07-15 70 views
-2

我在我的熊貓數據框中有很多列,我想用特定的方法清理。我想看看是否有辦法一次完成此操作。遍歷列以清理值

這是我試過的,這不起作用。

list = list(bigtable) # this list has all the columns i want to cleanse 

for index in list: 

    bigtable1.column = bigtable.column.str.split(',', expand=True).apply(lambda x: pd.Series(np.sort(x)).str.cat(sep=','), axis=1) 
+0

我不知道我是否應該推敲這個封閉的,但是這看起來可能是一個http://stackoverflow.com/questions/11346283重複/ renaming-columns-in-pandas/16667215#16667215 –

+0

我的不好。請注意標題中的編輯。 – Anu

+0

你可以發佈一個樣本輸入數據集(或列)和所需的數據集,因爲它不清楚你想實現什麼? – MaxU

回答

1

試試這個應該工作:

bigtable1=pd.Dataframe() 

for index in list: 

    bigtable1[index] = bigtable[index].str.split(',', expand=True).apply(lambda x: pd.Series(np.sort(x)).str.cat(sep=','), axis=1)