When using pandas to filter excel,
df.loc[df['threat_type'].str.contains("DGA")]
The following error messages appear:
ValueError: Cannot mask with non-boolean array containing NA/NaN values
It is reported that the grouping column contains non-string contents. Because the use of .Str.contains requires that the field must be a string and cannot have numbers,
so it is added to the code
df.loc[df['threat_type'].str.contains("DGA", na=False)]
This enables the function to directly ignore non-string situations.
Read More:
- Error reading file by pandas pandas.errors.EmptyDataError: no columns to parse from file
- Pandas read_csv pandas.errors.ParserError: Error tokenizing data
- [resolution] str.contains() problem] valueerror: cannot index with vector containing Na/Nan values
- Python: How to Reshape the data in Pandas DataFrame
- [Solved] Pandas rename Error: ValueError: operands could not be broadcast together with shapes (1,2) (3,) (1,2)
- Python: ___ () vs ___ str__()
- Python TypeError: Unrecognized value type: <class ‘str‘>dateutil.parser._parser.ParserError: Unknow
- Implementation of Kalman Filter in Python
- [Solved] Python3.9 Pycropto RSA Error: TypeError: can’t concat str to bytes
- How to Fix pandas.errors.ParserError Error tokenizing data C error Buffer overflow caught
- Python Pandas Error: KeyError: 0 [How to Solve]
- Pandas Error: ValueError: setting an array element with a sequence.
- Python Pandas Typeerror: invalid type comparison
- [Solved] AttributeError: ‘str‘ object has no attribute ‘decode‘
- Pandas ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.an
- How to Solve Python Pandas Read or Import Files Error
- [Solved] TypeError: unsupported operand type(s) for /: ‘str‘ and ‘int‘
- [How to Fix]pandas.errors.ParserError: Error tokenizing data
- [Solved] AttributeError: module ‘pandas‘ has no attribute ‘rolling_count‘
- [Solved] Pytorch-transformers Error: AttributeError: ‘str‘ object has no attribute ‘shape‘