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:
- [resolution] str.contains() problem] valueerror: cannot index with vector containing Na/Nan values
- Python Valueerror: cannot index with vector containing Na / Nan values
- Python TypeError: Unrecognized value type: <class ‘str‘>dateutil.parser._parser.ParserError: Unknow
- [How to Fix] TypeError: Cannot cast array data from dtype(‘float64‘) to dtype(‘<U32‘)….
- Python: How to Reshape the data in Pandas DataFrame
- Python: LeetCode 43 Multiply Strings
- Python Time Module timestamp, Time string formatting and Conversion (13-bit timestamp)
- [Solved] Pandas rename Error: ValueError: operands could not be broadcast together with shapes (1,2) (3,) (1,2)
- Panda error in modifying line name index does not support mutable operations
- Python Openyxl Error: AttributeError: ‘int‘ object has no attribute ‘upper‘ [How to Solve]
- [Solved] Operator Not Allowed In Graph Error & Attribute Error Tensor object has no attribute numpy
- numpy.concatenate() 253rd; 38169Keyerror: 0 [How to Solve]
- Pandas read_csv pandas.errors.ParserError: Error tokenizing data
- [Solved] TypeError: not all arguments converted during string formatting
- Python 3.X error: valueerror: data type must provide an itemsize
- Extracting Data from XML (Using Python to Access Web Data)
- python2.7 ExcelWriter error Exception caught in workbook destructor. Explicit close() may be require
- Pandas Error: ValueError: setting an array element with a sequence.
- Python parsing JSON Error: NameError: name ‘false’ is not defined
- Python Error: ValueError: invalid literal for int() with base 16: ‘ ‘