我有看起来像这样的数据集。我有两个类别的月份数据,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)
通过 Using df.index.week,我没有得到预期的周值,而是像这样给了我一年中的周数。
请指导?
