-3

I have this data frame:

its a print of the first lines of my dataframe, it have around 11k lines its made of twitter data

I was using: df.loc[(df["screen_name"]=="vagnerfsm")] to get specific lines that have tweets made by this user

but I still don't know how to get lines from a specific day: df.loc[(df["created_at"]=="Mon May 25")] <- I believe i need some specific code, like * in excel, to make it understand that I want all data that begin with "Mon May 25". Whats should I put?

Yeah, its a noob question, but I'm learning python since a few weeks, so.. if someone can help... suggestions are welcome

davidbilla
  • 2,120
  • 1
  • 15
  • 26
FabioMathu
  • 13
  • 1
  • Please provide a small set of sample data as text that we can copy and paste. Include the corresponding desired result. Check out the guide on [how to make good reproducible pandas examples](https://stackoverflow.com/a/20159305/3620003). – timgeb Jun 16 '20 at 07:49

1 Answers1

0

You can apply the column "created_at" to datetime using

df['created_at'] = pd.to_datetime(df['created_at'],format = '%a %b %d %H:%M:%S %z %Y')

to cast to datetime. The format is in https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior

When you want to get lines from specific day, 25 May 2020, you can filter the day using

df[df['created_at'].dt.date==pd.Timestamp(2020,5,25)]