I was given a dataset by my professor and one of my questions is, "Find the number of missing values, 99999, in each column and list them." How would I do this in python? I have multiple columns all with numerical data.
The missing values in the dataset are denoted by ‘99999’ instead of NA like usual.
I don’t have much experience in python and have tried many things to no avail
>Solution :
Use a lambda function to find all occurrences of 99999; then use sum() to get the total number of occurrences per column
# import pandas package
import pandas as pd
# load dataset with pandas, for example if you have a csv:
df = pd.read_csv("YOUR_FILEPATH_HERE")
# print out the number of occurrences of 99999 in each column
print(df.apply(lambda x: (x == 99999).sum()))