인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

veryycherry's profile image
veryycherry

asked

Getting started with Python data analysis using public data

[17/21] Finding the frequency and ratio of parks by city/province

merge 질문있습니다

Written on

·

195

1

안녕하세요 선생님


city = city_count.merge(city_mean, left_index=True, right_index=True)
해당 코드에서 left_index 또는 right_index만 True로 설정하면 안되는 건가요..?
numpypandaspython

Answer 1

0

todaycode님의 프로필 이미지
todaycode
Instructor

안녕하세요.

양쪽 인덱스 값이 같은 것끼리 묶어주는 옵션이기 때문에 한쪽만 지정해도 값을 연결해 줄 수 있다면 상관이 없겠지만 양쪽 인덱스 값을 고려해야 한다면 둘 다 지정해 주어야 합니다.

인덱스 대신 left_on 이나 right_on 으로 특정 컬럼을 지정하는 방법도 있습니다.

veryycherry님의 프로필 이미지
veryycherry
Questioner

앗 그럼 left or right 방식으로 하게 되면 한쪽만 지정해도 되나요?

todaycode님의 프로필 이미지
todaycode
Instructor

안녕하세요.

양쪽 컬럼 값이 다르면 둘 다 지정해 주셔야 하고 같다면 on 이라는 것으로 지정해 주시면 됩니다.

veryycherry's profile image
veryycherry

asked

Ask a question