오류 질문
430
equalsocial
20 asked
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']
pandas
python
Answer 2
1
df_count['output'] = df_count['amount'] / df_count['salary']
위와 같이 연산 하는 경우 값이 복사되어서 연산을 하기 때문에 속도가 느려질 수 있어서 나오는 경고 입니다.
.loc를 이용할 것을 권장하는 메세지 입니다.
수강기간즘연장해주세요
0
3
1
작업형3 기출
0
6
1
유형2에서 데이터분할 생략 가능여부
0
7
1
9회 기출 유형3 질문
0
7
1
lgb 기초편
0
5
1
수업자료 문의
0
7
1
괄호 사용
0
8
1
작업형 2 데이터 전처리 질문
0
9
0
11회 기출 유형 작업형1 문제 3-1
0
8
0
7회 3유형 2번문제 질문
0
7
1
예시문제 작업형2 (ver2023) 질문입니다
0
10
1
Data type에 따른 처리
0
6
1
Cursor 실행 문의
1
11
2
데이터 전처리 관련
0
13
2
시험에서 문제 불러오기
0
12
2
2번문제 출력값 질문
0
17
2
index 부여
0
356
3
엑셀정렬
0
538
6
판다스 불러오기중
0
411
3
안녕하세요 판다스 오류떠서 질문드립니다
0
409
1
기존 ipynb 파일(파이썬) 을 파이참으로 오픈할 수있는 방법이 있나요?
0
1416
1
print('hello') 라고 치면 아래 워닝이 뜨면서 실행이 안되네요..?
0
253
1
조건에 따른 데이터프레임 수정 방법이 가능한지, 어떤 방식으로 가능한지 궁금해요.
0
376
1
판다스 데이터 처리에 대한 질문입니다.
0
296
2

