0

I'm working on titanic data right now, using pandas. Funny thing is, when dealing with missing values, drorpna() does not work but notna() does.

temp.Embarked.dropna(inplace = True)
temp.isnull().sum()

Embarked 2

temp = temp[temp['Embarked'].notna()]
temp.isnull().sum()

Embarked 0

M_x
  • 782
  • 1
  • 8
  • 26
em seoyk
  • 1
  • 1
  • 1
    `temp.Embarked.dropna(inplace = True)` does nothing since it works on a slice of the dataframe. `temp.dropna(subset=['Embarked'], inplace=True)` might. – Quang Hoang Feb 01 '21 at 04:57
  • 1
    @QuangHoang well, not a slice, but a single column, but yeah – juanpa.arrivillaga Feb 01 '21 at 04:58
  • 4
    Simply [`notna()`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.notna.html) will return True if element is not null , while [`dropna()`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.dropna.html) removes elements which are null. – k33da_the_bug Feb 01 '21 at 05:11

1 Answers1

1

I think both done same process, but when we are using dropna() we have to mention how the way we have to drop Nan means, by axis....

you have to mention row wise or column wise

Eg:temp.Embarked.dropna(inplace = True,axis=1)

it will drop the nan values with entire row

for further clarification please refer this link below:

Here's What does axis in pandas mean?