Data Frame:
JavaScript
x
7
1
Unnamed: 0 date target insult tweet year
2
0 1 2014-10-09 thomas-frieden fool Can you believe this fool, Dr. Thomas Frieden 2014
3
1 2 2014-10-09 thomas-frieden DOPE Can you believe this fool, Dr. Thomas Frieden 2014
4
2 3 2015-06-16 politicians all talk and no action Big time in U.S. today - MAKE AMERICA GREAT AG 2015
5
3 4 2015-06-24 ben-cardin It's politicians like Cardin that have destroy... Politician @SenatorCardin didn't like that I s 2015
6
4 5 2015-06-24 neil-young total hypocrite For the nonbeliever, here is a photo of @Neily 2015
7
I want the data frame which consists for only year with 2020 and 2021 using search and match methods.
Advertisement
Answer
JavaScript
1
2
1
df_filtered = df.loc[df.year.str.contains('2014|2015', regex=True) == True]
2