目前我有以下格式的表格:Geo-id Name stat Year index
111500 Anniston-Oxford-Jacksonville AL 1991 0
111500 Anniston-Oxford-Jacksonville AL 1992 91.675
111500 Anniston-Oxford-Jacksonville AL 1993 93.8025
111500 Anniston-Oxford-Jacksonville AL 1994 96.63
111500 Anniston-Oxford-Jacksonville AL 1995 99.455
111500 Anniston-Oxford-Jacksonville AL 1996 102.4875
111500 Anniston-Oxford-Jacksonville AL 1997 109.0225
111500 Anniston-Oxford-Jacksonville AL 1998 114.7075
111500 Anniston-Oxford-Jacksonville AL 1999 116.005
112220 Auburn-Opelika AL 1992 90.695
112220 Auburn-Opelika AL 1993 94.2075
112220 Auburn-Opelika AL 1994 98.6825
112220 Auburn-Opelika AL 1995 103.3675
112220 Auburn-Opelika AL 1996 107.2725
112220 Auburn-Opelika AL 1997 111.7125
应将其转换为:
^{pr2}$
保持大地水准面和名称垂直(但仅重复一次,因为它是水平旋转的)。在
到目前为止我掌握的代码:pre_horizontal_df = pd.read_csv('database_raw.csv')
pre_horizontal_df['period'] = pre_horizontal_df.year.astype(str)
df1 = pre_horizontal_df.groupby(['geoid', 'name'])['hpi'].mean().unstack()
print (df1)
但这是行不通的。这个水平轴可以用python df/pandas完成吗?在