반응형
가격데이터, 수량데이터 가져오기
vegetable_price.csv
0.00MB
vegetable_quantity.csv
0.00MB
import pandas as pd
%matplotlib inline
price_df = pd.read_csv('./data/vegetable_price.csv')
quantity_df = pd.read_csv('./data/vegetable_quantity.csv')
price_df
quantity_df
Inner Join (Product 컬럼 기준으로 데이터 합치기)
pd.merge(price_df, quantity_df, on='Product')
- Product 컬럼에서 공통적으로 가지고 있는 값만 출력
Left Outer Join
pd.merge(price_df, quantity_df, on='Product', how='left')
- price_df 에 있는 column 값들은 출력
- quantity_df와 겹치는 값이 없는 column 값들은 NaN
Right Outer Join
pd.merge(price_df, quantity_df, on='Product', how='right')
- quantity_df 에 있는 모든 column 값들은 출력
- price_df 와 겹치는 값이 없는 column 값들은 NaN
Full Outer Join
pd.merge(price_df, quantity_df, on='Product', how='outer')
- price_df , quantity_df 에 있는 모든 column 값들은 출력
- 서로 겹치는 값이 없는 column 값들은 NaN
반응형
'Python > Pandas' 카테고리의 다른 글
[DataAnalysis] Clustering (0) | 2024.01.31 |
---|---|
[Pandas] 파이 차트 (0) | 2024.01.23 |
[Pandas] groupby 카테고라이징 (0) | 2024.01.22 |
[Pandas] 문자열 필터링 (0) | 2024.01.16 |
[Pandas] 데이터 클리닝 (0) | 2024.01.05 |