问题描述
我的问题与this one有些相关。我有一个 Pandas DataFrame,我想分别为 value
中的每个项目绘制 category
的自相关函数。下面是我尝试过的,它在同一个图上绘制了所有的自相关函数。如何分别绘制它们并控制绘图大小?
# Import libraries
import pandas as pd
from pandas.plotting import autocorrelation_plot
# Create DataFrame
df = pd.DataFrame({
'category': ['sav','sav','check','cd','cd'],'value': [1.2,1.3,1.5,1.7,1.8,10,13,17,20,25,7,8,8.5,9,9.3]
})
# Loop through for each item in category and plot autocorrelation function
for cat in df['category'].unique():
s = df[df['category']==cat]['value']
s = s.diff().iloc[1:] #First order difference to de-trend
ax = autocorrelation_plot(s)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)