ValueError: cannot index with vector containing NA / NaN values

One other possible issue: you can get this with mixed-type columns that do not contain NaN. For example:

> df = pd.DataFrame({'x': ['hi', 99]})
> df.x.isna().any()
False
> df[df.x.str.contains('hi')]
...
ValueError: cannot index with vector containing NA / NaN values

Depending on what you want to do, you can cast (df.x.astype(str).str.contains('hi')) or drop the offending rows.


The error message means that the dataframe contains blank entries that default to na/NaN.

You can just add na=False in the synatx to fill value for missing values.

import csv
import os
import pandas as pd
os.chdir('C:\\Users\\khalha\\Desktop\\RealExcel')
filename = 'sales.csv'

Sales = pd.read_csv('sales.csv')
iFlowStatus = Sales[Sales['Product'].str.contains('iFlow', na=False)]['Status']
print(iFlowStatus)