Having the following dataframe:
| name | aaa | bbb |
|---|---|---|
| Mick | None | None |
| Ivan | A | C |
| Ivan-Peter | 1 | None |
| Juli | 1 | P |
I want to get two dataframes.
- One with values, where we have None in columns
aaaand/orbbb, namedfilter_nullsin my code - One where we do not have None at all.
df_outin my code.
This is what I have tried and it does not produce the required dataframes.
import pandas as pd
df_out = {
'name': [ 'Mick', 'Ivan', 'Ivan-Peter', 'Juli'],
'aaa': [None, 'A', '1', '1'],
'bbb': [None, 'C', None, 'P'],
}
print(df_out)
filter_nulls = df_out[df_out['aaa'].isnull()|(df_out['bbb'] is None)]
print(filter_nulls)
df_out = df_out.loc[filter_nulls].reset_index(level=0, drop=True)
print(df_out)