difference between drop and dropna in pandas data frame
what is the difference between drop and dropna in pandas data frame?
1 answers ( 0 marked as helpful)
Hey Soumya,
Thank you for your question!
The drop()
method drops specific labels from a column or a row. For example, the code
data = raw_data.drop(['Model'], axis=1)
will remove the entire 'Model' column from the dataframe.
The dropna()
method, on the other hand, removes observations containing missing values. For example, the code
data_no_mv = data.dropna(axis=0)
drops all rows (i.e. observations) that contain missing values.
Hope this helps!
Kind regards,
365 Hristina