■ concat 함수를 사용해 N개의 DataFrame 객체를 순서대로 결합하는 방법을 보여준다.
▶ main.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import pandas as pd no2DataFrame1 = pd.read_csv("air_quality_no2_long.csv", parse_dates = True) no2DataFrame2 = no2DataFrame1[["date.utc", "location","parameter", "value"]] pm25DataFrame1 = pd.read_csv("air_quality_pm25_long.csv",parse_dates = True) pm25DataFrame2 = pm25DataFrame1[["date.utc", "location","parameter", "value"]] concatDataFrame = pd.concat([no2DataFrame2, pm25DataFrame2], axis = 0) # axis : 0(행), 1(컬럼) print(concatDataFrame.head()) """ date.utc location parameter value 0 2019-06-21 00:00:00+00:00 FR04014 no2 20.0 1 2019-06-20 23:00:00+00:00 FR04014 no2 21.8 2 2019-06-20 22:00:00+00:00 FR04014 no2 26.5 3 2019-06-20 21:00:00+00:00 FR04014 no2 24.9 4 2019-06-20 20:00:00+00:00 FR04014 no2 21.4 """ |
▶ requirements.txt
1 2 3 4 5 6 7 8 |
numpy==2.1.2 pandas==2.2.3 python-dateutil==2.9.0.post0 pytz==2024.2 six==1.16.0 tzdata==2024.2 |
※ pip install pandas 명령을 실행했다.
air_quality_no2_long.csv
air_quality_pm25_long.csv