首页 > 解决方案 > 如何在 Google Colab 中使用 matplotlib 避免格式错误?

问题描述

代码错误 我正在尝试从谷歌 Colab 中的 csv 绘制时间序列数据,并收到以下错误:

ValueError:格式字符串中无法识别的字符a

这是我的代码:

df = pd.read_csv("/content/drive/My Drive/hospital project/fastpass stuff.csv")

df.date = pd.to_datetime(df['date'])

df_all_units = df.groupby([pd.Grouper(key='date', freq='30min')]).size().reset_index(name='number of events')

df_all_units.to_csv("/content/drive/My Drive/hospital project/all_units.csv")

from matplotlib import pyplot as plt
plt.figure()
plt.plot('number of events', 'date')
plt.title('Visitors Over Time')
plt.xlabel('Time')
plt.ylabel('Number of Visitors')
#plt.show()

标签: pythonmatplotlibplottime-series

解决方案


推荐阅读