81

醜く見える:

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])]

上記の「問題」のエレガントで実用的な解決策はありますか?

4

2 に答える 2

174

イシンを使う

df_new[df_new['l_ext'].isin([31, 22, 30, 25, 64])]
于 2013-08-15T10:05:29.127 に答える