IndexingError: Unalignable boolean Series provided as indexer (index of the boolean Series and of the indexed object do not match).
问题:索引列未对齐
原因:1、NumPy的any()用法;2、索引数据过程
关于any():
-
Python内置的any()
- any(iterable) 如果可迭代对象iterable中的任何项为 true,则返回 True
| 但凡内部含有__iter__方法的对象,都是可迭代对象
- any(iterable) 如果可迭代对象iterable中的任何项为 true,则返回 True
-
NumPy的any()
- any(a, axis=None, out=None, keepdims=np._NoValue)
- 用来判断(二维)数组中 某个轴向上 是否有一个元素为True
-
Pandas的any()
- DataFrame.any(self, axis=0, bool_only=None, skipna=True, level=None, **kwargs)
- 常和isnull()联合使用 > 判空
栗子1:
#Python内置
python = np.arange(10)
x = any(python)
print(x) #返回True
x2 = 1
y = any(x2) #会直接报错:'int' object is not iterable
print(y)
栗子2:
#NumPy的any:
"""
any(a, axis=None, out=None, keepdims=np._NoValue)
Test whether any array element along a given axis evaluates to True.
Returns single boolean unless axis is not None
"""
numpy = np