Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- seaborn
- 포인터
- 클래스
- plot
- 동적할당
- histplot
- value_counts
- 한빛미디어
- catplot
- c++
- boxplot
- lmplot
- LOC
- expand=true
- 혼공학습단
- 혼공단
- stripplot
- const
- 구조체
- 혼공파
- class
- violinplot
- 참조자
- STR
- Axis
- bins
- 열혈c++
- swarmplot
- df.t
- matplotlib
Archives
- Today
- Total
yEverything
데이터 합치기 본문
import pandas as pd
price_df = pd.read_csv('vegetable_price.csv')
quantity_df = pd.read_csv('vegetable_quantity.csv')
price_df
quantity_df
두 개의 csv파일 읽어서 각각 price_df와 quantity_df에 저장하기.
각각 이런 데이터가 들어있다.
pd.merge(price_df, quantity_df, on='Product')
pandas의 merge를 사용해서 price와 quantity를 product 기준으로 합친다.
price를 먼저 적었으므로 price에서 quantity의 값들이 합쳐졌다.
pd.merge(price_df, quantity_df, on='Product', how='left')
how에 대해서는 아래의 그림 참고. 디폴트는 inner이다.
그래서 위에서 inner로 합쳐진 것을 알 수 있다.
없는 값들은 NaN으로 표시되었다.
pd.merge(price_df, quantity_df, on='Product', how='outer')
outer로 합치기.
'Data_analysis > Google_colaboratory' 카테고리의 다른 글
데이터 클리닝-유일성 (0) | 2024.05.03 |
---|---|
데이터 클리닝-완결성 (0) | 2024.05.03 |
카테고리로 분류 (0) | 2024.05.03 |
문자열 필터링 (0) | 2024.05.03 |
문자열 분리 (0) | 2024.05.03 |