I am using this dataset and reading it through pandas dataframe. I need to work with the paperAbsrtract
column only which has some missing data.
filename = "sample-S2-records"
df = pd.read_json(filename, lines=True)
abstract = df['paperAbstract']
Because there are some missing data in the abstract
dataframe, I want to remove those rows that are empty. So following the documentation, I do below
abstract.dropna(how='all')
But this doesn't remove those empty rows. They are still there in the abstract
dataframe. What am I missing?
You are missing the inplace
argument by setting it to True
or assigning this function's result to your dataframe.
# Solution 1: inplace = True:
abstract.dropna(how='all', inplace = True)
# do operation inplace your dataframe and return None.
# Solution 2: assign the function result to your own dataframe:
abstract = abstract.dropna(how='all')
# don't do operation inplace and return a dataframe as a result.
# Hence this result must be assigned to your dataframe
Note: inplace
default value is False
.
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