질문있어요!
381
작성한 질문수 2
df.loc[df['age']>=30, ['name', 'value']]
이 부분이
TypeError Traceback (most recent call last) <ipython-input-108-dd0bf85b7488> in <module> ----> 1 df.loc[df['age']>=30, ['name', 'value']] ~\anaconda3\lib\site-packages\pandas\core\ops\common.py in new_method(self, other) 63 other = item_from_zerodim(other) 64 ---> 65 return method(self, other) 66 67 return new_method ~\anaconda3\lib\site-packages\pandas\core\ops\__init__.py in wrapper(self, other) 368 rvalues = extract_array(other, extract_numpy=True) 369 --> 370 res_values = comparison_op(lvalues, rvalues, op) 371 372 return self._construct_result(res_values, name=res_name) ~\anaconda3\lib\site-packages\pandas\core\ops\array_ops.py in comparison_op(left, right, op) 242 243 elif is_object_dtype(lvalues.dtype): --> 244 res_values = comp_method_OBJECT_ARRAY(op, lvalues, rvalues) 245 246 else: ~\anaconda3\lib\site-packages\pandas\core\ops\array_ops.py in comp_method_OBJECT_ARRAY(op, x, y) 54 result = libops.vec_compare(x.ravel(), y.ravel(), op) 55 else: ---> 56 result = libops.scalar_compare(x.ravel(), y, op) 57 return result.reshape(x.shape) 58 pandas\_libs\ops.pyx in pandas._libs.ops.scalar_compare()
TypeError: '>=' not supported between instances of 'str' and 'int'
이렇게 오류가 뜨는데 어떻게 해결해야 하나요??
답변 2
0
해결하셨을 거 같긴한데, 혹시 도움이 될까 싶어 댓글 남겨요.
저도 웹크롤링한 다음 df.info로 보면 age, number가 int가 아니라 object로 나오더라구요. 그래서 전 웹크롤링해서 받는 코드를 int()로 감싸 int64로 형태를 변환시켰습니다. 이렇게 하면 int64로 age 내 value 형태가 변해서 위 에러가 없어질겁니다. 아래에 뷰티풀숲으로 코딩한 내용 중 int로 감싼 내용만 복붙할게요~
for i in player_info:
0
안녕하세요?
문자와 정수형 숫자를 비교할 때 생기는 오류 메시지인데..df['age'] >=30 이 부분에서 문제가 생긴 것 같습니다. df.info()로 'age'칼럼이 정수형인지(int64) 또 빠진 값은 없는 지 다시 확인해보실래요?
강의내용관련
0
11
1
본 강의와는 상관없는 내용입니다만..
0
9
1
강의 만료 후 오프라인 저장 강의 수강 가능 여부
0
18
2
Part03 프롬프트 14 기간 조정(횡보 후 돌파) 입력 시 claude에서 수정안 발생
0
8
0
xgboost에 관해
0
18
2
수업노선자료파일 다운
0
12
1
best of best 점수 합산
0
23
1
code 노드 Execute step 관련 질문
0
19
2
기출문제 pdf 없음
0
24
2
antigravity로 하던 작업 이제 visual code로 하면 되는 거죠?
0
28
1
다음 강의 얼른 올려주세요
0
22
2
빅데이터분석기사 작업2형
0
31
2
.env 파일 질문입니다.
0
27
2
깃허브에서 csv파일 불러오기 오류 문의
0
532
2
국적 2개 출력
0
236
1
player_info =soup.find_all('tr' ) 로 선수 정보를 뽑지 않은 이유
0
263
0
9:57 데이터 변경 .astype()
0
210
0
수업 듣던중 오류가 발생하여 문의드립니다. 확인 부탁드려요ㅜㅜ
0
204
0
player_info = soup.find_all('tr', class_ = ['odd', 'even]) 함수가 동작하지 않습니다.
0
371
1
df.info에서 자료형태 질문있습니다.
0
227
0
error
0
214
0
transfermarkt.com 페이지에 대해서 status_code가 404로 오류가 나타납니다.
0
244
0
강의 10:00 분쯔음 player 에 값 넣기
0
446
1
number.append질문
0
488
5





