0

I have a dataframe called winter_df with two columns...

            Germany_consumption     Date

Date        

2018-01-01  44360.125000    2018-01-01

2018-01-02  56385.958333    2018-01-02

2018-01-03  61500.500000    2018-01-03

2018-01-04  61227.375000    2018-01-04

2018-01-05  60049.333333    2018-01-05

I would like to make a simple scatter plot using Date as the X column and Germany_consumption as the y column.

However, when I attempt to do this I get the following error:

winter_df.plot.scatter(x='Date',y='Germany_consumption')

ValueError: scatter requires x column to be numeric

I can map the date to an ordinal value using the map() function, but then my x-axis xtick values are numeric rather than the datetime format that I want.

I couldn't find any satisfactory answers myself when researching this so I'm wondering if anyone has a good solution for how to do this.

Thanks

Quang Hoang
  • 146,074
  • 10
  • 56
  • 74
redmage123
  • 413
  • 8
  • 15
  • You can try, for example [this answer](https://stackoverflow.com/questions/50939270/matplotlib-scatter-cannot-use-time-as-x-axis) – Quang Hoang Jul 28 '20 at 06:33
  • [see here](https://stackoverflow.com/questions/38256750/make-a-scatter-plot-in-matplotlib-with-dates-on-x-axis-and-values-on-y) – RakeshV Jul 28 '20 at 09:35

0 Answers0