【发布时间】:2014-04-09 11:59:02
【问题描述】:
问题
如何在 Pandas 中执行按位运算?
& 如何处理整数
& 运算符在整数上执行按位掩码
>>> mask = 0b1100 # 4 and 8 bits on
>>> 7 & mask
4
& 在 Pandas 中的工作原理
有没有办法在 Pandas 中执行按位屏蔽操作? & 运算符做了其他事情。
>>> df = DataFrame([1, 2, 3, 4, 5, 6, 7, 8], columns=['data'])
>>> df.data & mask
0 False
1 False
2 False
3 True
4 True
5 True
6 True
7 True
Name: data, dtype: bool
【问题讨论】:
标签: python pandas bit-manipulation