0

enter image description herei am trying to analyze a dataset with twitts. i have sentiment and country as columns, as well as the date of the twitt.

i would like to show the average sentiment per date for two different countries and i can't find the way around it.

how do i plot the average sentiment per day? and hoy do i show just the twitts for "united kingom" for example?

the image attached was done with the following code:

fig, ax = plt.subplots(2,1, sharey=True)
ax[0].plot(dff['just_date'].tolist(), dff['sentiment'], marker=".", linestyle="None", color="r")
ax[0].set_xlabel("Time")
ax[0].set_ylabel("Sentiment")
ax[0].set_title("Sentiment vs. Time")
ax[1].plot(dff['just_date'].tolist(), dff['sentiment'], marker=".", linestyle="None", color="b")
ax[1].set_xlabel("Time")
ax[1].set_ylabel("Sentiment")
ax[1].set_title("Sentiment vs. Time")
plt.show()

thanks!

i would like to show the average sentiment per date for two different countries and i can't find the way around it.

enter image description here

natalie
  • 9
  • 2
  • Can you post a sample of the data you are using? – MichaelB Mar 24 '23 at 17:17
  • hello michael, images are now added :) – natalie Mar 24 '23 at 17:25
  • 3
    Please avoid images of data, instead provide it in markdown table format, or as the result of `dff.head().to_dict()` – BigBen Mar 24 '23 at 17:28
  • `dfp = df.pivot_table(index='just_date', columns='country', values='sentiment', aggfunc='mean')` and `ax = dfp[['united states of america', 'united kingdom']].plot(figsize=(10, 6), title='Sentiment vs. Time', xlabel='Time', ylabel='Sentiment')` – Trenton McKinney Mar 24 '23 at 20:07

0 Answers0