如何从熊猫数据框中选择的列表中检查值?
问题描述:
看起来很丑:
df_cut = df_new[
(
(df_new['l_ext']==31) |
(df_new['l_ext']==22) |
(df_new['l_ext']==30) |
(df_new['l_ext']==25) |
(df_new['l_ext']==64)
)
]
不起作用:
df_cut = df_new[(df_new['l_ext'] in [31, 22, 30, 25, 64])]
是否存在上述问题"的优雅且可行的解决方案?
Is there an elegant and working solution of the above "problem"?