오류 질문
430
김보준
작성한 질문수 20
0
import pandas as pd
df_amount = pd.read_csv("amount_per_year.csv")
df_employee = pd.read_csv("employee_list.csv")
df_merged = pd.merge(df_amount, df_employee, on='id')
#print(df_merged)
df_count = df_merged[(df_merged['amount']>=10) \
& (df_merged['year'] == 2020)]
#print(df_count)
df_count['output'] = df_count['amount'] / df_count['salary']
df_count = df_count.sort_values(['output'])
print(df_count)
위와 같이 코드를 짜니 아래와 같은 오류가 떴습니다. 문제가 뭐였을까요?
C:/Users/equal/PycharmProjects/pandas_practice/merge_exercise/01-2 merge_exercise.py:12: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
df_count['output'] = df_count['amount'] / df_count['salary']
답변 2
1
df_count['output'] = df_count['amount'] / df_count['salary']
위와 같이 연산 하는 경우 값이 복사되어서 연산을 하기 때문에 속도가 느려질 수 있어서 나오는 경고 입니다.
.loc를 이용할 것을 권장하는 메세지 입니다.
26년 1회실기
0
5
1
26,27강 진행 간 노션, html 프롬프트 파일 불일치
0
13
3
강의 자료
0
16
1
27:15 break 출력
0
13
1
kaggle notebook에 service key 설정이 누락된 것 같습니다
1
21
2
수업 노트가 안 보입니다.
0
22
1
Python formatter 설치
0
23
1
55강 파이썬에만있는 연산자들
0
30
2
55강의 파이썬에서만 있는 연산자들
0
24
2
주말에 실행할 경우 update_economic_data_in_background에 로직 변경 필요성
1
31
1
naver 글자 수집 오류 건
0
24
1
쥬피터 노트북이 실행이 안됩니다.
0
28
1
뒤로가기 버튼 같은 것이 있나요?
0
28
1
Replit 강의 자료가 안나와요
0
20
1
강의 연장 문의
0
32
1
프로그램 실행시간에 대한 질문
1
25
2
index 부여
0
356
3
엑셀정렬
0
542
6
판다스 불러오기중
0
412
3
안녕하세요 판다스 오류떠서 질문드립니다
0
409
1
기존 ipynb 파일(파이썬) 을 파이참으로 오픈할 수있는 방법이 있나요?
0
1417
1
print('hello') 라고 치면 아래 워닝이 뜨면서 실행이 안되네요..?
0
255
1
조건에 따른 데이터프레임 수정 방법이 가능한지, 어떤 방식으로 가능한지 궁금해요.
0
378
1
판다스 데이터 처리에 대한 질문입니다.
0
298
2





