fips year sc
0 1001 1990 -0.707465
1 1001 1991 -0.707465
2 1001 1992 -0.707465
3 1001 1993 -0.707465
4 1001 1994 -0.707465
5 1001 1995 -0.707465
6 1002 1996 -0.707465
7 1002 1997 -0.607672
8 1002 1998 -0.607672
9 1002 1999 -0.607672
10 1002 2000 -0.607672
11 1002 2001 -0.607672
12 1002 2002 -0.607672
我想通过 fips 组计算 sc 变量的自相关。我尝试了代码:
test=sc_itpl.groupby('fips')['sc'].autocorr(lag=1)
我收到错误:
AttributeError:无法访问可调用属性“autocorr”
“SeriesGroupBy”对象,尝试使用“apply”方法
您可以使用GroupBy.apply:
test=sc_itpl.groupby('fips')['sc'].apply(lambda x: x.autocorr(lag=1))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)