import pandas as pd
from matplotlib import pyplot as plt
acsv=pd.read_csv('full_data.csv')
acsv.drop([2,5],axis=0,inplace=True)
booliens=[]
for i in acsv.new_deaths:
tip=str(i)
if "nan" in tip:
booliens.append(False)
else:
booliens.append(True)
booliens=pd.Series(booliens)
booliens.shape
форма серии booliens: (2865,)
acsv.shape
форма ACSV DataFrame: (2865, 6)
acsv[booliens]
Ошибка:
C:\Users\Asgar Aliyev\anaconda3\lib\site-packages\ipykernel_launcher.py:1: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
"""Entry point for launching an IPython kernel.
---------------------------------------------------------------------------
IndexingError Traceback (most recent call last)
<ipython-input-63-99a794a359e7> in <module>
----> 1 acsv[booliens]
~\anaconda3\lib\site-packages\pandas\core\frame.py in __getitem__(self, key)
2789 # Do we have a (boolean) 1d indexer?
2790 if com.is_bool_indexer(key):
-> 2791 return self._getitem_bool_array(key)
2792
2793 # We are left with two options: a single key, and a collection of keys,
~\anaconda3\lib\site-packages\pandas\core\frame.py in _getitem_bool_array(self, key)
2841 # check_bool_indexer will throw exception if Series key cannot
2842 # be reindexed to match DataFrame rows
-> 2843 key = check_bool_indexer(self.index, key)
2844 indexer = key.nonzero()[0]
2845 return self._take_with_is_copy(indexer, axis=0)
~\anaconda3\lib\site-packages\pandas\core\indexing.py in check_bool_indexer(index, key)
2315 if mask.any():
2316 raise IndexingError(
-> 2317 "Unalignable boolean Series provided as "
2318 "indexer (index of the boolean Series and of "
2319 "the indexed object do not match)."
IndexingError: Unalignable boolean Series provided as indexer (index of the boolean Series and of the indexed object do not match).
первое значение booliens и acsv - same.it должно работать, когда я пишу эту команду 'acsv [booliens]'. Но она не работает. Когда я удаляю
acsv.drop([2,5],axis=0,inplace=True)
эту строку, я не получаю никакой ошибки, и она работает хорошо. И получаю такие же формы