循环遍历列以清除值

时间:2016-07-15 04:14:46

标签: python pandas

我的pandas数据框中有很多列,我想用特定的方法清理它。我想看看是否有办法一次性完成这项工作。

这是我尝试的,但这不起作用。

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) 

1 个答案:

答案 0 :(得分: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) 
相关问题