5

I have a pretty simple dataframe as seen below. I am trying to manipulate the x-axis(dates) so it starts at 1996-31-12 and ends at 2016-31-12 on increments of 365 days.

Datafame:

Date             A             B  
1996-31-12       10            3
1997-31-03       5             6
1997-31-07       7             5
1997-30-11       3             12
1997-31-12       4             10
1998-31-03       5             8
.
.
.
2016-31-12       3             9

#change date string to datetime variable
df12.Date = pd.to_datetime(df12.Date)

fig, ax = plt.subplots()
ax.plot_date(df12.Date,df12.A)
ax.plot_date(df12.Date,df12.B)
ax.xaxis.set_major_locator(mdates.YearLocator())

ax.xaxis.grid(True, which="major")
ax.yaxis.grid()
ax.xaxis.set_major_formatter(mdates.DateFormatter('%b\n%Y''))
plt.tight_layout()
plt.show()

I am getting an error message when i try and run the above code that I am not sure what it means-OverflowError: Python int too large to convert to C long. ANy one know what this means? If not, is there another way to do what i want to do?

spacedinosaur10
  • 695
  • 3
  • 10
  • 24
  • Apart from the typo in the dateformatter ( `('%b\n%Y')` instead of `('%b\n%Y'')` ) this should work fine. For further investigation you'd need to provide a true [mcve]. – ImportanceOfBeingErnest Mar 13 '17 at 21:32
  • Check this one out too... https://stackoverflow.com/questions/26642133/why-do-i-get-python-int-too-large-to-convert-to-c-long-errors-when-i-use-matpl , Though i have similar trouble with the latest versions of everything – ntg Nov 24 '17 at 09:31

0 Answers0