강의

멘토링

커뮤니티

Inflearn Community Q&A

equalsocial's profile image
equalsocial

asked

Analyzing and processing data with Python Pandas

Are performance and salary proportional?

index 부여

Written on

·

334

0

csv파일 두 개 모두에 index가 없다고 가정해 보았습니다.

df.reset_index().rename(columns={"index": "id"})

으로 index를 넣으니 amount_per_year에는 0~11까지 부여되고 employee_list에는 0-5까지 부여됐습니다. 

원래의 amount_per_year의 파일처럼 id에 0~6, 0~6으로 넣으려면 어떻게 해야할까요? 

pandaspython

Answer 3

0

equalsocial님의 프로필 이미지
equalsocial
Questioner

파일 업로드가 안되는데, amout_test와 employee_test는 원본에서 id값을 지운 파일들 입니다.

0

equalsocial님의 프로필 이미지
equalsocial
Questioner

import pandas as pd

df_amount = pd.read_csv("amount_test.csv")
df_employee = pd.read_csv("employee_test.csv")

df_amount = df_amount.reset_index().rename(columns={"index":"id"})
df_employee = df_employee.reset_index().rename(columns={"index":"id"})
print(df_amount)
print(df_employee)

df_merged = pd.merge(df_amount, df_employee, on='id')
#print(df_merged)

0

Kyeongrok Kim님의 프로필 이미지
Kyeongrok Kim
Instructor

데이터와 코드를 올려주시겠어요?

equalsocial's profile image
equalsocial

asked

Ask a question