How do I check if there is a column filled with only 'None' values? How do I drop that column?
So something similar to:
If column in dataframe is None:
drop column
Here's a dummy data example where the solution should identify the 5th column as empty and drop that column:
import pandas as pd
import numpy as np
# dictionary of lists
dict = {'First Score':[100, np.nan, np.nan, 95],
'Second Score': [30, np.nan, 45, 56],
'Third Score':[52, np.nan, 80, 98],
'Fourth Score':[60, 67, 68, 65],
'Fifth Score':[ np.nan, np.nan, np.nan, np.nan]
}
# creating a dataframe from dictionary
df = pd.DataFrame(dict)
df = df.where(pd.notnull(df), None)