I have the following data:
import pandas as pd
data = {'var1': ['pero03930', 'pero03930', ' '],
'var2': ['121324', '232434', ' '],
'var3': [343, 937, 989],
}
df = pd.DataFrame (data, columns = ['var1', 'var2', 'var3'])
print(df)
I'm trying to develop a function that identifies the missing values and this is what I have so far:
def missing_values(var1, var2, var3):
if var1 is None:
return 'Missing var1 in data'
if var2 is None:
return 'Missing var2 in data'
if var3 is None:
return 'missing var3 value in data'
else:
return 'No missing values in data'
print(missing_values(df))
I get this error:
TypeError: missing_values1() missing 2 required positional arguments: 'var2' and 'var3'
I know this is because the function is trying to find the two other parameters. How do I get the function to recognize that the parameters are within the data set? Or is there generally a better way to write this function?