I have a dataframe that I would like to chunck- or rather run temporal sentiment analysis at different times. I am trying to measure how sentiment changes as part of user identity in extremist social movements. My data comes from Twitter.

How can I group users based on a date range? Say:

2021-01-01 23:59:15+00:00 - 2021-01-06 23:59:15+00:00   

I tried to split the data using something like the code below but it does not constrain the data to specific date range

split_date ='2022-03-06 14:54:58+00:00' 
cluster_data = df.loc[df['created_at'] <= split_date]
  • $\begingroup$ hey, did you try df['created_at'] = pd.to_datetime(df['date'], format="%Y-%d-%m %H:%M:%S"), doing the same for split_date and then trying cluster_data = df.loc[df['created_at'] <= split_date] ? $\endgroup$ May 4 at 18:52
  • $\begingroup$ Thank you for the answer. I ended up creating a weekly cohort of across the entire timeframe which in addition to clustering allowed me to follow the users over time and see change in user identity weekly. $\endgroup$
    – Falah Amro
    May 10 at 4:17


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.