
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
2주차 숙제에서는 간단한 사항만 요구해서 숙제자체는 문제가 없었는데요.
강의에서 활용한, 그룹바이 코드를 활요해 보려고 하니 에러가 나서 질문드립니다.
글루코스를 강의에서 설명해주신 age 처럼 나눠서 그룹화 해보려고 했는데 어렵네요ㅠㅠ
보고 계

신 화면 전체를 캡처해 주시면, 튜터님들이 빠르게 상황을 이해할 수 있어요.
작성한 코드 및 에러 메세지
오류homework['Glucose'].hist(bins=40,figsize=(18,8),grid=True)
homework['Glucose_cat'] = pd.cut(titanic['Glucose'],bins=[0, 50, 100, 150, 200],include_lowest=True,labels=['1-50','50-100','100-150','150-200'])
homework.groupby('Glucose_cat').mean()
plt.figure(figsize=(14,5))
sns.barplot(x='Glucose_cat',y='Outcome',data=homework)
plt.show()
위와 같이 입력했고, 아래 오류 메세지가 나왔어요.
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
3801 try:
-> 3802 return self._engine.get_loc(casted_key)
3803 except KeyError as err:
4 frames
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'Glucose'
The above exception was the direct cause of the following exception:
KeyError Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
3802 return self._engine.get_loc(casted_key)
3803 except KeyError as err:
-> 3804 raise KeyError(key) from err
3805 except TypeError:
3806 # If we have a listlike key, _check_indexing_error will raise
KeyError: 'Glucose'
