This is a the dataframe in pandas I have
dict = {'First Score':[100, 90, np.nan, 95],
'Second Score': [30, 45, 56, np.nan],
'Third Score':[np.nan, 40, 80, 98]}
# creating a dataframe from dictionary
df = pd.DataFrame(dict)
I am trying to eliminate rows with NA values at once. So is there a way to do this through loops For example I am trying this on 1 column like below
df_first_score = pd.notnull(df['First Score']) ### find not null values
df[df_first_score]
First Score Second Score Third Score
0 100.0 30.0 NaN
1 90.0 45.0 40.0
3 95.0 NaN 98.0
So this way I am doing for all columns manually. Is there a way to achieve this through loops? So that I get below output
final_df
First Score Second Score Third Score
1 90.0 45.0 40.0
I know this can be done in other ways, But wanted to know if we can achieve this through loops