Python 类型错误:无法在<;上标记索引;类别';pandas.core.Index.base.Index'&燃气轮机;

Python 类型错误:无法在<;上标记索引;类别';pandas.core.Index.base.Index'&燃气轮机;,python,pandas,Python,Pandas,因此,我正在使用的代码试图将年份和季度放入数据帧中,如2020Q1、2020Q2等。但我遇到了一个类型错误,我不确定如何修复它 TypeError: cannot do label indexing on <class 'pandas.core.indexes.base.Index'> with these indexers [0] of <class 'int'> 19 for i in range(0,len(crisis_df)): ---> 20

因此,我正在使用的代码试图将年份和季度放入数据帧中,如2020Q1、2020Q2等。但我遇到了一个类型错误,我不确定如何修复它

TypeError: cannot do label indexing on <class 'pandas.core.indexes.base.Index'> with these indexers [0] of <class 'int'> 
19 for i in range(0,len(crisis_df)):
 ---> 20     date_idx = 
pd.to_datetime(crisis_df.loc[i,'SERVICE_DATE'], format='%Y-%m-%d')
 21     crisis_df.loc[i,'Quarter'] = str(date_idx.year) + "Q" + str(date_idx.quarter)
TypeError:无法使用的这些索引器[0]对进行标签索引
范围(0,len(危机)中的i为19:
--->20日期\u idx=
pd.to_datetime(crisis_df.loc[i,'SERVICE_DATE',格式=“%Y-%m-%d”)
21危机发生地点[i,'季度]=str(日期/年份)+“Q”+str(日期/季度)
附上图片。感谢您的帮助

图像描述