1categories = train_X[train_X.dtypes =='category'].columns
2# IndexingError: Unalignable boolean Series provided as indexer (index of the boolean Series and of the indexed object do not match).
1>>>print(train_X)2 cat_1 cat_2 num_1
30113.3241231.4552212.226>>>print(train_X.dtypes =='category')7cat_1 True8cat_2 True9num_1 False10dtype:bool11>>>print(train_X[train_X.dtypes =='category'])12>>print(train_X)13 cat_1 cat_2 num_1
140113.32151231.45162212.2217>>>print(train_X.dtypes =='category')18cat_1 True19cat_2 True20num_1 False21dtype:bool22>>>print(train_X[train_X.dtypes =='category'])23<stdin>:1: UserWarning: Boolean Series key will be reindexed to match DataFrame index.24Traceback (most recent call last):25 File "<stdin>", line 1,in<module>26 File "C:\Users\shinp\anaconda3\lib\site-packages\pandas\core\frame.py", line 2791,in __getitem__
27return self._getitem_bool_array(key)28 File "C:\Users\shinp\anaconda3\lib\site-packages\pandas\core\frame.py", line 2843,in _getitem_bool_array
29 key = check_bool_indexer(self.index, key)30 File "C:\Users\shinp\anaconda3\lib\site-packages\pandas\core\indexing.py", line 2317,in check_bool_indexer
31raise IndexingError(32pandas.core.indexing.IndexingError: Unalignable boolean Series provided as indexer (index of the boolean Series and of the indexed object do not match).
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/03/07 17:22