I have this code that allows me to find all blanks in certain columns of a dataframe. Here is what I have:
req_cols = ['First Name*','Last Name*','Country*','Company*','Email Address*']
bad_nan=df[df[req_cols].isna().any(1)]
I am trying to add the missing cells or NAN values to an existing dictionary called "errors"
if not bad_nan.empty:
errors.append({
"row": [0],
"column": [1],
"message": "This is a required field"
})
this is what the dictionary looks like:
{'row': [0], 'column': [1], 'message': 'This is a required field'}
but I would like it to look like
{'row': 2, 'column': First Name*, 'message': 'This is a required field'}
I would like this to display all the cells that have a NaN value not just one