오류
학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요!
질문과 관련된 영상 위치를 알려주면 더 빠르게 답변할 수 있어요
먼저 유사한 질문이 있었는지 검색해보세요
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로 쓰니까 안되나요
Câu trả lời 2
0
순서 문제 맞아요
test[cols]에서 '성별' 컬럼이 없는데 cols에 사용해서 에러가 발생합니다
0
test[cols]에서 '성별' 컬럼이 없는건 이해했는데
cols에 성별을 사용했다는게 무슨 말인지 모르겠씁니다 ㅜㅜㅜ
cols= 부분이랑
pop부분
순서만 바꿔주면 되던데
왜 꼭 그래야만 하는지 이유를 모르겠어요.......
ols
0
1
0
2유형 작성관련 질문(일반 심화)
0
11
1
2유형 작성관련 질문
0
8
1
2유형 object컬럼 개수 다르면
0
10
1
코딩팡질문이요ㅠㅠ
0
12
1
관찰값과 기대값의 개념이 헷갈립니다.
0
11
1
작업형2 ID 컬럼 삭제 질문
0
20
2
2유형 작성관련 질문
0
10
1
memoryerror 질문
0
12
1
작업형 유형2 이렇게 고정 템플릿으로 가져가도 될까요?
0
13
0
ID 삭제 필수 인가요?
0
17
3
7회 기출문제 작업형1번 df 변환 후 저장되는 방식 질문
0
13
1
3 유형 귀무가설, 대립가설
0
19
2
인코딩 관련 질문 있습니다
0
21
2
작업형3 이원분산분석 sm에서불러오기 / anova_lm 차이
0
21
2
2유형 원핫인코딩 오류
0
22
2
시험장에서 주석 단축키 안될 때 많나요?
0
26
2
라벨인코딩 방식
0
24
2
test 재학습 관련
0
15
2
target 빈도 확인
0
17
2
작업형 2 연습문제 섹션 6
0
20
2
F1-score
0
19
2
작업형 2번 섹션 3
0
18
2
작업형 2 인코딩, 결측치, 모델 선택 질문
0
22
1

