I have a pandas question about getting a name if a range of values is true from an X column. If year is inside its decade from 1960 until now, print the Name So here is an example of my dataframe:
#,Name,description,year
1,a,foo,1961
2,a,foo2,1977
3,a,foo3,1980
4,a,foo4,1995
5,a,foo5,2001
6,a,foo6,2011
7,a,foo7,2020
8,b,bar,1965
9,b,bar2,1970
10,b,bar3,1983
11,b,bar4,1997
12,b,bar5,2005
13,b,bar6,2016
14,b,bar7,2022
15,c,abc,1965
16,c,ab2,1970
17,c,abc3,1993
18,c,abc4,2007
19,c,abc5,2015
20,c,abc6,2020
Output: a,b
So far, I did this:
dataset[Year].str.match(str(year[0:3]))
I think I need a for loop for this, but I am not sure at all. Thank you for any help!