Reputation: 29
I have a dataframe with a whole lotta rows and 21 columns. I'm using this code to filter out the rows with blank values in the 'date' column.
master = pd.read_excel('master.xlsx')
master.loc[master['date'] != 'NaN']
I use 'NaN because that's what the values show up as when I print the master object. However, they are written as "NA" in the Excel document I sourced the info from. Even replacing 'NaN' with 'NA' still outputs a dataframe with the rows I am trying to exclude. Even replacing 'NaN' and 'NA' with '' still outputs the rows I am trying to exclude.
Upvotes: 0
Views: 75
Reputation: 20445
you can use pandas builtin function to filter not nan values in df , for example with notnull()
master = master[master['date'].notnull()]
Upvotes: 2