Home > front end >  change the year range when plotting with seaborn
change the year range when plotting with seaborn

Time:12-06

myDataTradeSWE = myDataTrade[(myDataTrade['from']=='SWE') & (myDataTrade['Year'] > 2013)]

myDataTradeSWE.head(10)

How can I change the year range so it only shows 2014 AND 2018 ?

CodePudding user response:

You probably mean or, not and, since a row can't be 2014 AND 2018 at the same time :)

myDataTradeSWE = myDataTrade[(myDataTrade['from']=='SWE') & ((myDataTrade['Year'] == 2014) | (myDataTrade['Year'] == 2018))]

CodePudding user response:

You need to replace your > with ==, and then you need to add | (myDataTrade ['Year'] == 2018).

If I understand correctly you search, your code should look like this. This will change the range of the year when plotting:

myDataTradeSWE = myDataTrade[(myDataTrade['from']=='SWE') &
    ((myDataTrade['Year'] == 2014) | (myDataTrade['Year'] == 2018))]

myDataTradeSWE.head(10)
  • Related