0

enter image description here

I'm trying to plot "created_at" versus "rating".

"Created_at" is datetime format

enter image description here

Why is the x-axis being shown as float values instead of dates like I am intending with the line

plt.plot(data['created_at'].values, data['rating'],"b.", alpha =0.5)

shown in the bottom picture

user2892730
  • 31
  • 1
  • 7

1 Answers1

0

The easiest way to achieve this is to define a temporary dataframe with the datetimes as index (see this SO post):

rating_vs_creationdate = data.copy()
rating_vs_creationdate = rating_vs_creationdate.set_index('created_at')
rating_vs_creationdate = rating_vs_creationdate['rating']
plt.plot(rating_vs_creationdate)

Maybe you will run into problems with the date format. The link provided by MrFuppes in the comments gives an easy date formatting example.

above_c_level
  • 3,579
  • 3
  • 22
  • 37