■ DataFrame 클래스의 rename 메소드에서 columns 인자를 사용해 컬럼명을 변경하는 방법을 보여준다.
▶ 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 25 26 |
import pandas as pd airQualityNO2DataFrame = pd.read_csv("air_quality_no2_long.csv") renameAirQualityNO2DataFrame = airQualityNO2DataFrame.rename(columns = {"date.utc" : "datetime"}) print(renameAirQualityNO2DataFrame) """ city country datetime location parameter value unit 0 Paris FR 2019-06-21 00:00:00+00:00 FR04014 no2 20.0 µg/m³ 1 Paris FR 2019-06-20 23:00:00+00:00 FR04014 no2 21.8 µg/m³ 2 Paris FR 2019-06-20 22:00:00+00:00 FR04014 no2 26.5 µg/m³ 3 Paris FR 2019-06-20 21:00:00+00:00 FR04014 no2 24.9 µg/m³ 4 Paris FR 2019-06-20 20:00:00+00:00 FR04014 no2 21.4 µg/m³ ... ... ... ... ... ... ... ... 2063 London GB 2019-05-07 06:00:00+00:00 London Westminster no2 26.0 µg/m³ 2064 London GB 2019-05-07 04:00:00+00:00 London Westminster no2 16.0 µg/m³ 2065 London GB 2019-05-07 03:00:00+00:00 London Westminster no2 19.0 µg/m³ 2066 London GB 2019-05-07 02:00:00+00:00 London Westminster no2 19.0 µg/m³ 2067 London GB 2019-05-07 01:00:00+00:00 London Westminster no2 23.0 µg/m³ [2068 rows x 7 columns] """ |
▶ 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 명령을 실행했다.