【发布时间】:2021-09-08 06:32:02
【问题描述】:
我的数据集看起来像 this。我有两个类别的月份数据,62 行,每个类别 31 行。我想在 y 轴上创建一个带有周数和月份的每周箱线图 [如 01-12、02-12、03-12 等]。
到目前为止,我已经想出了以下代码。
import seaborn as sns
import matplotlib.pyplot as plt
sns.set()
fig, ax = plt.subplots(figsize=(18,6))
df.index = pd.to_datetime(df.Timestamp)
sns.boxplot(x=df.index.week, y='Values', data=df, hue='Category', ax=ax)
通过使用df.index.week,我没有得到预期的周值,而是给了我一年中的周数,例如this。
请指导?
【问题讨论】:
标签: python pandas seaborn boxplot