pandas add a filter to a column

>>> df['E']=['a','a','c','b']
>>> df
A B C D E
0 -0.018330 2.093506 -0.086293 -2.150479 a
1 0.104931 -0.271810 -0.054599 0.361612 a
2 0.590216 0.218049 0.157213 0.643540 c
3 -0.254449 -0.593278 -0.150455 -0.244485 b
>>> df.E.isin(['a','c'])
0 True
1 True
2 True
3 False
Name: E, dtype: bool

======================

No isnotin, its inverse function is preceded by ~, other usage ibid.

Guess you like

Origin www.cnblogs.com/yjybupt/p/11014702.html