Код: Выделить всё
date_range = pd.date_range(start='2023-01-01', periods=10)
data = {
'Category A': np.random.randint(1, 10, 10),
'Category B': np.random.randint(1, 10, 10),
}
df = pd.DataFrame(data, index=date_range)
Код: Выделить всё
df['total'] = df.sum(axis=1)
df['rolling'] = df['total'].rolling(window=7).mean()
Код: Выделить всё
ax = df[['Category A', 'Category B']].plot(kind='bar', stacked=True)
df['rolling'].plot(kind='line', ax=ax)
Подробнее здесь: https://stackoverflow.com/questions/786 ... -in-pandas