Quite a simple question, have tried several things with no luck.
I'm trying to isolate age ranges of customers whose birth dates fall in a certain interval.
youth = cd.loc[cd.yearofbirth.isin([1996, 1997 1998, 1999]), "SALES"]
works fine however, some of the other intervals are larger (i.e. include 30+ years) and I don't want to write them all out but rather do a less than or equal to and a more than or equal to. i.e.
youth = cd.loc[cd.yearofbirth >= 1996 | cd.yearofbirth <= 1999, "SALES"]
but this line of code gives me a error
TypeError: cannot compare a dtyped [float64] array with a scalar of type [bool]
A single inequality works fine, but its when combining it with a second which makes it error.
help greatly appreciated!