尝试使用datetime数据时pandas数据集OverflowError

时间:2017-11-10 16:30:54

标签: python pandas matplotlib

延续自:Getting date/time and data out of csv into matplotlib

import datetime
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import matplotlib.cbook as cbook
import pandas
import StringIO

f = open(r'clean data.csv')

#Make a string buffer and read in the CSV file while stripping \x00's
output = StringIO.StringIO()
for x in f.readlines():
    output.write(x.replace('\x00',''))

#Close out input file
f.close()

#Set position back to start for pandas to read
output.seek(0)
df = pandas.read_csv(output, skiprows=38, parse_dates=['Time'], index_col="Time")
fig, ax = plt.subplots()
ax.plot(df.index,df['108 <Air> (C)'])
#ax.xaxis.set_major_locator(mdates.DayLocator())
#ax.format_xdata = mdates.DateFormatter('%Y-%m-%d')
#fig.autofmt_xdate()
plt.show()

所以我实际上可以用这个当前代码绘制这些数据,当我尝试继续这个例子时会出现问题:https://matplotlib.org/gallery/api/date.html#sphx-glr-gallery-api-date-py

如果你取消注释

ax.xaxis.set_major_locator(mdates.DayLocator())

我得到了

OverflowError: Python int too large to convert to C long

那是什么?

以下是一些输入数据:https://pastebin.com/SSZyaSJ4

0 个答案:

没有答案