inflearn logo
강의

Course

Instructor

Analyzing and processing data with Python Pandas

Merging and filtering biotech data

오류 질문

440

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

Kyeongrok Kim

 df_count['output'] = df_count['amount'] / df_count['salary']
위와 같이 연산 하는 경우 값이 복사되어서 연산을 하기 때문에 속도가 느려질 수 있어서 나오는 경고 입니다.
.loc를 이용할 것을 권장하는 메세지 입니다.

0

equalsocial

답변 감사합니다:) 

영상 다운로드는 안되나요?

0

3

0

수강자료 다운로드 관련 문의

0

11

2

Opus/Sonnet 버전 관련 문의

1

12

2

"run_nvidia_gpu.bat" 실행후

0

10

1

섹션2 질문이요

1

16

2

섹션 2

0

11

1

섹션1.9 질문입니다!

1

20

3

웹서비스 방법

0

19

1

MCP 정의가 잘못되어 있음 (Chapter2)

0

21

1

수강 연장 문의드립니다.

0

27

2

13. (App 2) 기본기 훈련 에서

0

29

1

채점 프로그램 미작동

0

20

2

챌린지 시작일 문의

0

33

0

2. 어떤 도구를 사용하는 것이 가장 유리할까? 강의 중

0

27

1

안녕하세요 ppt 자료 메일로 부탁드립니다

0

18

1

11차시 Antigravity IDE 설치 후

0

30

1

index 부여

0

370

3

엑셀정렬

0

560

6

판다스 불러오기중

0

433

3

안녕하세요 판다스 오류떠서 질문드립니다

0

423

1

기존 ipynb 파일(파이썬) 을 파이참으로 오픈할 수있는 방법이 있나요?

0

1434

1

print('hello') 라고 치면 아래 워닝이 뜨면서 실행이 안되네요..?

0

264

1

조건에 따른 데이터프레임 수정 방법이 가능한지, 어떤 방식으로 가능한지 궁금해요.

0

393

1

판다스 데이터 처리에 대한 질문입니다.

0

312

2