小编3tw*_*zzy的帖子

我有 8 年的每日数据。我想绘制一周中每天、一年中的每周和一年中的每个月的所有值。我怎么做?

我希望能够将我的数据点可视化为一周中的每一天、一年中的每一周和每月。我能够每年可视化我的数据。但是当我调整每月和每周的代码时,x 轴仍然是每年。

我有8年的住院记录。我的数据被组织成 2 列。第 1 列是我的“日期”列,从 2010-03-10 开始到 2017-12-31 结束。第 2 列是我的值列。本专栏列出了我是否有患者前来接受治疗。第 2 列中的值为 0 或 x 数字。例如 0 表示我没有患者 x 表示我有 x 名患者。当我尝试以图形方式表示这些数据时,它只计算我每周拥有的最大 x 数。

df=pd.read_csv('Data 3.csv', parse_dates=["Dates"], index_col="Dates")
# create the plot space upon which to plot the data
fig, ax = plt.subplots(figsize = (10,10))

# add the x-axis and the y-axis to the plot
ax.plot(df.resample('Y').sum()['Total # Events'],color = 'blue')

# rotate tick labels
plt.setp(ax.get_xticklabels(), rotation=45)

# set title and labels for axes
ax.set(xlabel="Years",
ylabel="Total # of …
Run Code Online (Sandbox Code Playgroud)

python data-visualization matplotlib pandas

5
推荐指数
1
解决办法
1547
查看次数

标签 统计

data-visualization ×1

matplotlib ×1

pandas ×1

python ×1