inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

파이썬 판다스(pandas)로 데이터 분석 및 가공하기

생명 공학 데이터 합치고 필터링하기

오류 질문

435

김보준

작성한 질문수 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']

pandas python

답변 2

1

Kyeongrok Kim

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

0

김보준

답변 감사합니다:) 

수업자료와 노션 공유 문제

0

12

3

python run.py 실행시 에러 문제

0

18

1

조건 반복문 질문: for 문 ?

0

14

0

54강 4분 41초에서 질문 있어요.

0

13

1

커서창

1

22

2

강의 제작

1

26

1

23강 질문드립니다, 강사님.

0

17

1

import

0

12

1

45강 예제4번에서 질문 있어요!

0

17

1

45강 강의 10분 03초 내용에서 x + 1 을 하는 이유는 뭔가요?

0

15

1

Json.stringify 관련 오류일까요?

0

16

2

3강, 7강 화면이 안나옵니다. 그냥 검은화면으로만 노출되요;;

0

20

1

cursor 환경

1

28

2

Gradio 실행 시 에러 발생 문의

0

19

2

Gradio 실행 시 Jinja2 / ASGI TypeError: unhashable type: 'dict' 에러 문의

0

25

2

안녕하세요, 강의자료 요청드립니다

0

23

1

index 부여

0

366

3

엑셀정렬

0

547

6

판다스 불러오기중

0

419

3

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

0

416

1

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

0

1427

1

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

0

259

1

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

0

385

1

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

0

304

2