pandas 데이터 합치기

hello0U0·2022년 11월 25일
0

기존 id를 지우고 index로 새로 id를 부여하여 저장

import pandas as pd
#합칠 데이터들
data_1 = pd.read_csv("")
data_2 = pd.read_csv(")
data_3 = pd.read_csv(")

new_df = pd.concat([data_1,data_2,data_3]) 
new_df = new_df.reset_index()
#index는 기존 데이터셋의 reset_index시 index로 자동생성된다.
new_df = new_df.drop(['id','index'],axis=1)
new_df.index.name = 'id'
new_df.to_csv("new_data.csv",index=True)
profile
hello world

0개의 댓글