为什么我的for循环中会出现错误“活动-内心日”?

时间:2018-11-14 11:18:53

标签: python data-science

在此代码中,请说明为什么发生此错误。我会 如果有人感兴趣,请分享更多代码。

fit_statsHR=auth2_client.intraday_time_series('activities/heart',base_date=date, detail_level='1sec')
time_list = []
val_list = []
ids = []
dates = []
for i in fit_statsHR['activities-heart-intraday']['dataset']:
  val_list.append(i['value'])
  time_list.append(i['time'])
  ids.append(id)
  dates.append(date)

heartdf=pd.DataFrame({'heartRate':val_list,'time':time_list,'userId':ids,'date':dates})

导致:

KeyError                                  Traceback (most recent call last)


<ipython-input-3-076c9750910b> in get_hps(auth2_client, id, date)
     51     ids = []
     52     dates = []
---> 53     for i in (fit_statsHR['activities-heart-intraday']['dataset']):
     54         val_list.append(i['value'])
     55         time_list.append(i['time'])

KeyError: 'activities-heart-intraday'

0 个答案:

没有答案