Last answered:

12 Nov 2021

Posted on:

11 Nov 2021

1

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)
Instructor
Posted on:

12 Nov 2021

1

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

Submit an answer