Hello, I am trying to filter two columns in a dataset. One filter is a selection type, the other filter will be to include key words in a description. I do not understand the error codes that I am getting. Any ideas how I could get the program to show the filtered results?
1 2 3 |
filt = [ (df[ 'Type of breach' ]! = 'HACK' ) & (df[ 'Description of incident' ]. str .contains( 'bank account' or 'social security number' , na = False ))] df[filt] |
Error: ValueError Traceback (most recent call last)
<ipython-input-15-fe2f66bc4df2> in <module>
----> 1 df[filt]
~\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)
2836 elif len(key) != len(self.index):
2837 raise ValueError(
-> 2838 f"Item wrong length {len(key)} instead of {len(self.index)}."
2839 )
2840
ValueError: Item wrong length 1 instead of 9015.