看起来很丑:
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])]
有没有一个优雅且有效的解决上述“问题”的解决方案?
pandas
语法中不太直观的特性之一... 除非你知道,否则你不会知道。 - openwonk进行否定应该足以实现不在isin中的操作。df_new[df_new['l_ext'].isin([31, 22, 30, 25, 64])] - Arun Das[{a, b}, {c, d}, {e, f}]
,其中a, b, c...
是一些值(比如字符串)。谢谢。 - undefined