In the following code I get a “KeyError: 0”.
import pandas as pd
import math
data = pd.read_csv(…) #file name and other parameters
data.columns=['UNIX_UTC_Time', 'Home_Team', …] #columns names
matches_number=len(data.index)
def check_data_quality():
for x in range (matches_number):
for y in range (11): #number of columns
if y==1 or y==2: #these columns are strings
continue
if math.isnan(data.at[x,y]):
print('NaN in:',data.at[x,y],'row',data.iloc[x])
check_data_quality()
Using loc instead of iloc doesn't help either.
If I remove data.columns line, then everything works.
Please let me know how I can print (whole) rows with unintended NaNs here.
Thank you!