col != ['SourceFile','Label']
df['FileDescription']=df[col].apply(lambda row:'_'.join(row.values.astype(str)),axis=1)
我想合并除“SourceFile”和“Label”两列之外的所有列中的元素。我试过上面的代码。这导致了值错误。有这么多专栏。所以我不能用
col=['SourceFile','AggregationType','APP14Flags0','APP14Flags1','Application','ArchivedFileName','Artist',.....]
df['FileDescription']=df[col].apply(lambda row:'_'.join(row.values.astype(str)),axis=1)
col != ['SourceFile','Label']
在语法上是错误的,它给出的是名称错误,而不是值错误。 首先获取不需要的列并将其转换为set现在将所有列设置为:
最后,将设置的差异作为列表分配回:
现在您可以使用聚合方法:
参见示例执行:
相关问题 更多 >
编程相关推荐