강의

멘토링

커뮤니티

Inflearn Community Q&A

kshhp54474068's profile image
kshhp54474068

asked

Pandas Pandas Data Analysis Basics Practice

Merge two dataframes

컬럼명이 다를 경우 어떻게 합치나요?

Written on

·

318

0

l1 = [{'name':'John','job':'teacher'},

    {'name':'John','job':'teacher'},

    {'name':'John','job':'teacher'}]

l2 = [{'이름':'Ed','직업':'dentist'},

    {'이름':'Jack','직업':'farmer'},

    {'이름':'Ted','직업':'designer'}]

이런 경우 어떻게 합치나요?

pandas

Answer 1

0

df2의 컬럼명을 df1과 동일하게 수정 후, concat하면 어떨지요?

df2.rename(columns={'이름':'name', '직업':'job', inplace=True}

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

 

아니면, merge를 써야 할 것 같은데,

좀 더 구글링 하시면 될 것 같네요..

kshhp54474068's profile image
kshhp54474068

asked

Ask a question