Skip to main content

dealing_with_null_values

Summarizing Null Values

ds.isna().sum()

Removing Null Values

In order to drop all the rows which have a null value on any field we do:

ds.dropna(how='any')

In order to drop all the rows which have a null value on all the field we do:

ds.dropna(how='all')

In order to drop all the rows which have a null value on any field within a subset we do:

ds.dropna(subset = ['column', 'column2'], how='any')

In order to drop all the rows which have a null value on all the fields within a subset we do:

ds.dropna(subset = ['column', 'column2'], how='all')

Reaplacing Null Values

ds['column_name'].fillna(value='not assigned', inplace = True)
ds['columnname'].value_counts(dropna = False)