오류
학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요!
질문과 관련된 영상 위치를 알려주면 더 빠르게 답변할 수 있어요
먼저 유사한 질문이 있었는지 검색해보세요
import pandas as pd
train = pd.read_csv("data/customer_train.csv")
test = pd.read_csv("data/customer_test.csv")
pd.set_option('display.max_columns',None)
train['환불금액'] = train['환불금액'].fillna(0)
test['환불금액'] = test['환불금액'].fillna(0)
cols = train.select_dtypes(exclude='object').columns
target = train.pop('성별')
from sklearn.ensemble import RandomForestClassifier
rf = RandomForestClassifier()
rf.fit(train[cols], target)
pred = rf.predict_proba(test[cols])
print(pred)
오류
Makefile:6: recipe for target 'py3_run' failed
make: *** [py3_run] Error 1
Traceback (most recent call last):
File "/goorm/Main.out", line 29, in <module>
model.fit(train[cols], target)
File "/usr/local/lib/python3.9/dist-packages/pandas/core/frame.py", line 3511, in getitem
indexer = self.columns._get_indexer_strict(key, "columns")[1]
File "/usr/local/lib/python3.9/dist-packages/pandas/core/indexes/base.py", line 5782, in getindexer_strict
self._raise_if_missing(keyarr, indexer, axis_name)
File "/usr/local/lib/python3.9/dist-packages/pandas/core/indexes/base.py", line 5845, in raiseif_missing
raise KeyError(f"{not_found} not in index")
KeyError: "['성별'] not in index"
도와주세요 왜 select_dtypes로 쓰니까 안되나요
답변 2
0
순서 문제 맞아요
test[cols]에서 '성별' 컬럼이 없는데 cols에 사용해서 에러가 발생합니다
0
test[cols]에서 '성별' 컬럼이 없는건 이해했는데
cols에 성별을 사용했다는게 무슨 말인지 모르겠씁니다 ㅜㅜㅜ
cols= 부분이랑
pop부분
순서만 바꿔주면 되던데
왜 꼭 그래야만 하는지 이유를 모르겠어요.......
뒤로가기 버튼 같은 것이 있나요?
0
27
1
강의 연장 문의
0
31
1
출력값 질문
0
31
2
수업노트가 어디에 있나요?
0
29
1
실기시험 제출관련
0
160
2
6.20 작업형 2 과적합
0
169
3
코딩팡 장업형2 베이스 라인 인코딩 종류 질문
0
52
2
로지스틱회귀, 회귀
0
52
2
회귀 문제를 풀때 질문입니다.
0
59
1
불균형 처리 후 성능이 더 낮아졌다면,
0
66
2
실기 체험 제2유형 에러 문의
0
66
1
LIGHTGBM 으로 하면 pred값이 소수점 6자리까지 나오는게 맞나요
0
52
2
3번문제 등분산 가정
0
50
2
작업형3 target 형 변환 질문
0
38
2
[작업형1] 연습문제 섹션1 ~ 10 의 section4
0
40
3
원핫인코딩과 레이블 인코딩에서 concat
0
62
2
제2유형 질문입니다.
0
49
2
C()
0
44
2
작업형 2에서 strafity 적용 유무
0
53
2
수강 기간 연장 가능 여부 문의드립니다.
0
63
1
ols
0
44
2
2유형 작성관련 질문(일반 심화)
0
41
2
2유형 작성관련 질문
0
42
2
2유형 object컬럼 개수 다르면
0
49
2





