문제2번 질문있습니다!
0
학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요!
질문과 관련된 영상 위치를 알려주면 더 빠르게 답변할 수 있어요
먼저 유사한 질문이 있었는지 검색해보세요
cond1 = df['구분'] = '발생건수'
cond2 = df['구분'] = '검거건수'
df1 = df[cond1]
df2 = df[cond2]
df2
이렇게 입력했는데
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
/usr/local/lib/python3.12/dist-packages/pandas/core/indexes/base.py in get_loc(self, key)
3804 try:
-> 3805 return self._engine.get_loc(casted_key)
3806 except KeyError as err:
index.pyx in pandas._libs.index.IndexEngine.get_loc()
index.pyx in pandas._libs.index.IndexEngine.get_loc()
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: '발생건수'
The above exception was the direct cause of the following exception:
KeyError Traceback (most recent call last)
2 frames
/usr/local/lib/python3.12/dist-packages/pandas/core/indexes/base.py in get_loc(self, key)
3810 ):
3811 raise InvalidIndexError(key)
-> 3812 raise KeyError(key) from err
3813 except TypeError:
3814 # If we have a listlike key, _check_indexing_error will raise
KeyError: '발생건수'
왜 발생건수에 대한 오류가 뜨는거죠? 정말 샅샅히 오류를 찾아봤는데 선생님이 하신거랑 똑같이한거같은데 ㅠㅠ
답변 1
0
에러는 똑같지 않아서 발생하는 겁니다.
거짓말 안해요 ㅎㅎㅎ
= 와 == 는 달라요
=는 대입
==는 왼쪽과 오른쪽이 같은지 비교합니다.
비교연산자를 써야하는데 대입을 했네요!
아래와 같이 수정하면 됩니다
cond1 = df['구분'] == '발생건수'
cond2 = df['구분'] == '검거건수'
RandomForest vs lgb
0
11
1
전처리 관련질문
0
7
2
작업형3 기출
0
7
1
유형2에서 데이터분할 생략 가능여부
0
13
2
9회 기출 유형3 질문
0
10
1
lgb 기초편
0
8
1
괄호 사용
0
12
1
작업형 2 데이터 전처리 질문
0
14
1
11회 기출 유형 작업형1 문제 3-1
0
10
0
예시문제 작업형2 (ver2023) 질문입니다
0
12
1
Data type에 따른 처리
0
12
2
데이터 전처리 관련
0
14
2
시험에서 문제 불러오기
0
12
2
2번문제 출력값 질문
0
18
2
pd.get_dummies()가 bool로 반환
0
16
2
대응표본검정 레빈
0
20
3
단일표본검정 문제 유형
0
22
2
[작업형 3] 6~7. 카이제곱 검정
0
18
2
9회 작업형3 문제 1-1
0
35
2
최종답안 계산 방식 질문
0
20
1
시험 치기 전 급하게 질문 사항
0
35
2
유형3
0
29
2
작업형 2 연습문제 섹션 3
0
20
2
11 기출문제 ipynb파일
0
33
2





