I try to drop null values of column 'Age' in dataframe, which consists of float values, but it doesn't work. I tried
data.dropna(subset=['Age'], how='all')
data['Age'] = data['Age'].dropna()
data=data.dropna(axis=1,how='all')
It works for other columns but not for 'Age'
Pclass Fare Age Sex
0 3 7.2500 22.0 1
1 1 71.2833 38.0 0
2 3 7.9250 26.0 0
3 1 53.1000 35.0 0
4 3 8.0500 35.0 1
5 3 8.4583 NaN 1
6 1 51.8625 54.0 1
7 3 21.0750 2.0 1
Remove All Duplicate Rows from Pandas DataFrame You can set 'keep=False' in the drop_duplicates() function to remove all the duplicate rows. For E.x, df. drop_duplicates(keep=False) .
The drop_duplicates() method removes duplicate rows. Use the subset parameter if only some specified columns should be considered when looking for duplicates.
data.dropna(subset=['Age'])
would work, but you should either set inplace=True
or assign it back to data
:
data = data.dropna(subset=['Age'])
or
data.dropna(subset=['Age'], inplace=True)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With