I want to just keep the rows whose last column is either positive or zero or NaN.
Asked
Active
Viewed 65 times
1 Answers
1
Not really sure what you are going for given the lack of information. But you could use .loc to create and indicator column. Then you would be able to filter on the indicator column for the desired rows.
df.loc[df['Column'] > 0, 'Indicator'] = 'Positive'
df.loc[df['Column'] = 0, 'Indicator'] = 'Zero'
df.loc[df['Column'].isnull(), 'Indicator'] = 'NaN'

Brian
- 2,163
- 1
- 14
- 26