0

I have a dataframe that looks like this

    Year  Season
    2000  Winter
    2002  Winter
    2002  Summer
    2004  Summer
    2006  Winter

and I want to be able to remove all the rows with Winter so it look like this

    Year  Season
    2002  Summer
    2004  Summer
AMC
  • 2,642
  • 7
  • 13
  • 35
  • This seems like a rather basic task, what part of it is not covered by the many existing resources on Pandas? Please see [ask], [help/on-topic]. – AMC May 07 '20 at 23:00

1 Answers1

2

Like this:

df = df[df['Season']!='Winter']

Explanation: df['Season']!='Winter' returns a boolean mask that you can use to index the original dataframe, thereby dropping all rows where season is winter.

See here: How to select rows from a DataFrame based on column values?

Max Uppenkamp
  • 974
  • 4
  • 16
  • https://stackoverflow.com/questions/18172851/deleting-dataframe-row-in-pandas-based-on-column-value – AMC May 08 '20 at 16:00