You can remove one []
:
df_new = df[list]
Also better is use other name as list
, e.g. L
:
df_new = df[L]
It look like working, I try only simplify it:
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:]])
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…