Hi there!

I am a student studying computer science.

AI/Pandas 기초

13. 두개의 데이터프레임 합치기

만능성구 2020. 4. 24. 19:31
728x90

행으로 합치기

df1
df2

result = pd.concat([df1,df2] ,ignore_index = True)

 

ignore_index 앞에서도 나왔는데 행 index 중복 될까봐 이전 값 무시하는거

 

result = df1.append(df2, ignore_index = True)

똑같은 기능


열로 합치기

result = pd.concat([df1,df2],axis =1 ,ignore_index =True)
label = [1,2,3,4,5]
prediction = [1,2,2,4,4]

comparison = pd.DataFrame({'label' : label, 'prediction' : prediction})

이렇게 생긴다.

728x90