您可以删除一个
[]:
df_new = df[list]
也最好使用其他名称
list,例如
L:
df_new = df[L]
看起来工作正常,我只尝试简化一下:
L = []for x in df.columns: if not "_" in x[-3:]: L.append(x) print (L)
List comprehension:
print ([x for x in df.columns if not "_" in x[-3:]])

您可以删除一个
[]:
df_new = df[list]
也最好使用其他名称
list,例如
L:
df_new = df[L]
看起来工作正常,我只尝试简化一下:
L = []for x in df.columns: if not "_" in x[-3:]: L.append(x) print (L)
List comprehension:
print ([x for x in df.columns if not "_" in x[-3:]])