커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
for문 에러
undefined주차
북마크
강*종
댓글
3
추천
0
조회수
12
조회수
12
답변 완료

* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.

* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.


강의와 똑같이 작성한거 같은데, 에러가 나옵니다.






작성한 코드 및 에러 메세지

f = 31

for i in range(6) :

  for j in range(5,0,-1) :

    cohort_data.at[(f,j-1), 'user_id'] = int(cohort_data.at[(f,j), 'user_id']) + int(cohort_data.at[(f,j-1), 'user_id'])

  f = f+1



---------------------------------------------------------------------------
InvalidIndexError                         Traceback (most recent call last)
<ipython-input-32-f6d8a0c59e10> in <cell line: 2>()
      2 for i in range(6) :
      3     for j in range(5,0,-1) :
----> 4         cohort_data.at[(f,j-1), 'user_id'] = int(cohort_data.at[(f,j), 'user_id']) + int(cohort_data.at[(f,j-1), 'user_id'])
      5     f = f+1


4 frames

/usr/local/lib/python3.10/dist-packages/pandas/core/indexes/base.py in _check_indexing_error(self, key)
   5923             # if key is not a scalar, directly raise an error (the code below
   5924             # would convert to numpy arrays and raise later any way) - GH29926
-> 5925             raise InvalidIndexError(key)
   5926 
   5927     @cache_readonly

InvalidIndexError: (31, 5)오류 발생 시, 작성한 코드 전체와 에러 메시지를 첨부해 주세요.

Tip 1) </> 아이콘을 눌러 코드박스를 만들어 보세요.

Tip 2) Ctrl+A(맥의 경우 Command+A) 단축키로 코드를 한 번에 선택할 수 있어요!


취소
 공유
취소
댓글 0
댓글 알림
나의얼굴