728x90
๋ฐ์ํ
ํ๋ก๊ทธ๋๋ฐ ์ธ๊ณ๋ฅผ ํ๊ตฌํฉ์๋ค.
< ๋ฏธ๋ 1์ธ๋น ์ ๋ ฅ์๋น๋ ์์ธก, ์ ๊ธฐ์ธ ์์ธก, ์ ๊ธฐ ๋จ๊ฐ ๊ณ์ฐ๊ธฐ >
๋ฐ์ดํฐ ์ถ์ฒ
https://epsis.kpx.or.kr/epsisnew/selectEkesKepChart.do?menuId=010100
In [1]:
import pandas as pd
In [2]:
import matplotlib.pyplot as plt
1์ธ๋น ์ ๋ ฅ ์ฌ์ฉ๋¶
In [3]:
file_path = "./data/poweruse_total.csv"
df_poweruse_year = pd.read_csv(file_path, encoding='euc-kr')
df_poweruse_year
Out[3]:
์ฐ๋ | ๋ฐ์ ์ค๋น | Unnamed: 2 | Unnamed: 3 | Unnamed: 4 | Unnamed: 5 | ์ด๋ฐ์ ๋ | Unnamed: 7 | Unnamed: 8 | Unnamed: 9 | ... | Unnamed: 18 | ์ต๋์ ๋ ฅ(๋ฐ์ ๋จ)(MW) | ํ๊ท ์ ๋ ฅ(MW) | ๋ถํ์จ(%) | ์ด์ฉ์จ(%) | ์ดํจ์จ(%) | ํ๊ท ํ๋งค๋จ๊ฐ(์/kWh) | ๊ณ ๊ฐํธ์(์ฒํธ) | ์ข ์ ์์(๋ช ) | ์ธ๊ตฌ1์ธ๋น ์๋น์ ๋ ฅ๋(kWh/๋ช ) | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | NaN | ์๋ ฅ(MW) | ํ๋ ฅ(MW) | ์์๋ ฅ(MW) | ์๊ฐ์ฉ(MW) | ์ด๊ณ(MW) | ์๋ ฅ(GWh) | ํ๋ ฅ(GWh) | ์์๋ ฅ(GWh) | ์๊ฐ์ฉ(GWh) | ... | ์์์ฑ์ฅ๋ฅ (%) | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
1 | 2022.0 | 6513.123 | 80337.494 | 24650 | 5290.079 | 138194.755 | 7256.228 | 362201.282 | 176054.012 | 30650.791 | ... | 2.718 | 94509.0 | 67853.923 | 71.796 | 49.1002 | 41.65 | 120.507 | 24866.375 | 23563.0 | 10652.0798 |
2 | 2021.0 | 6541.335 | 80847.494 | 23250 | 5423.617 | 138482.028 | 6737.434 | 370750.105 | 158015.23 | 26152.804 | ... | 4.744 | 91141.0 | 65845.832 | 72.246 | 49.1310 | 41.53 | 108.110 | 24523.304 | 23288.0 | 10330.0370 |
3 | 2020.0 | 6505.768 | 80330.174 | 23250 | 4464.139 | 133391.583 | 7148.249 | 347157.194 | 160183.721 | 24783.489 | ... | -2.2 | 89091.0 | 62859.991 | 70.600 | 48.7000 | 41.14 | 109.800 | 24198.304 | 20970.0 | 9826.0000 |
4 | 2019.0 | 6508.103 | 80478.222 | 23250 | 4410.161 | 129091.579 | 6247.064 | 377844.247 | 145909.669 | 23407.545 | ... | -1.074 | 90314.0 | 64274.007 | 71.167 | 51.2810 | 40.70 | 108.658 | 23860.032 | 20531.0 | 10039.0000 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
74 | 1949.0 | 0 | 0 | 0 | 0 | 230.059 | 0 | 0 | 0 | 0 | ... | 0 | 115.0 | 74.763 | 65.000 | 0.0000 | 0.00 | 0.000 | 0.000 | 0.0 | 0.0000 |
75 | 1948.0 | 0 | 0 | 0 | 0 | 226.059 | 0 | 0 | 0 | 0 | ... | 0 | 122.0 | 79.007 | 65.000 | 0.0000 | 0.00 | 0.000 | 0.000 | 0.0 | 0.0000 |
76 | 1947.0 | 0 | 0 | 0 | 0 | 199.159 | 0 | 0 | 0 | 0 | ... | 0 | 146.0 | 94.607 | 65.000 | 0.0000 | 0.00 | 0.000 | 0.000 | 0.0 | 0.0000 |
77 | 1946.0 | 0 | 0 | 0 | 0 | 199.159 | 0 | 0 | 0 | 0 | ... | 0 | 119.0 | 77.183 | 65.000 | 0.0000 | 0.00 | 0.000 | 0.000 | 0.0 | 0.0000 |
78 | 1945.0 | 0 | 0 | 0 | 0 | 199.159 | 0 | 0 | 0 | 0 | ... | 0 | 115.0 | 81.202 | 71.000 | 0.0000 | 0.00 | 0.000 | 0.000 | 0.0 | 0.0000 |
79 rows × 28 columns
In [4]:
### ๊ฒฐ์ธก์น๊ฐ ์๋์ง ์ ๋ณด ํ์ธํ๊ธฐ
df_poweruse_year.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 79 entries, 0 to 78
Data columns (total 28 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 ์ฐ๋ 78 non-null float64
1 ๋ฐ์ ์ค๋น 79 non-null object
2 Unnamed: 2 79 non-null object
3 Unnamed: 3 79 non-null object
4 Unnamed: 4 79 non-null object
5 Unnamed: 5 79 non-null object
6 ์ด๋ฐ์ ๋ 79 non-null object
7 Unnamed: 7 79 non-null object
8 Unnamed: 8 79 non-null object
9 Unnamed: 9 79 non-null object
10 Unnamed: 10 79 non-null object
11 ์๋ด์ ๋ ฅ๋ 79 non-null object
12 Unnamed: 12 79 non-null object
13 ์์์ฉ์ ๋ ฅ๋(GWh) 78 non-null float64
14 ์ก์ ๋จ์ ๋ ฅ๋(GWh) 78 non-null float64
15 ์ก๋ฐฐ์ ์์ค๋ 79 non-null object
16 Unnamed: 16 79 non-null object
17 ํ๋งค์ ๋ ฅ๋ 79 non-null object
18 Unnamed: 18 79 non-null object
19 ์ต๋์ ๋ ฅ(๋ฐ์ ๋จ)(MW) 78 non-null float64
20 ํ๊ท ์ ๋ ฅ(MW) 78 non-null float64
21 ๋ถํ์จ(%) 78 non-null float64
22 ์ด์ฉ์จ(%) 78 non-null float64
23 ์ดํจ์จ(%) 78 non-null float64
24 ํ๊ท ํ๋งค๋จ๊ฐ(์/kWh) 78 non-null float64
25 ๊ณ ๊ฐํธ์(์ฒํธ) 78 non-null float64
26 ์ข
์
์์(๋ช
) 78 non-null float64
27 ์ธ๊ตฌ1์ธ๋น ์๋น์ ๋ ฅ๋(kWh/๋ช
) 78 non-null float64
dtypes: float64(12), object(16)
memory usage: 17.4+ KB
In [5]:
# ํ์ํ ์ด๋ง ์ถ์ถ
df_poweruse_selected = df_poweruse_year[['์ฐ๋', '์ธ๊ตฌ1์ธ๋น ์๋น์ ๋ ฅ๋(kWh/๋ช
)']].copy()
df_poweruse_selected
Out[5]:
์ฐ๋ | ์ธ๊ตฌ1์ธ๋น ์๋น์ ๋ ฅ๋(kWh/๋ช ) | |
---|---|---|
0 | NaN | NaN |
1 | 2022.0 | 10652.0798 |
2 | 2021.0 | 10330.0370 |
3 | 2020.0 | 9826.0000 |
4 | 2019.0 | 10039.0000 |
... | ... | ... |
74 | 1949.0 | 0.0000 |
75 | 1948.0 | 0.0000 |
76 | 1947.0 | 0.0000 |
77 | 1946.0 | 0.0000 |
78 | 1945.0 | 0.0000 |
79 rows × 2 columns
In [6]:
# ์ฒซ ํ ์ ๊ฑฐ
df_poweruse_selected = df_poweruse_selected.drop(0)
df_poweruse_selected
Out[6]:
์ฐ๋ | ์ธ๊ตฌ1์ธ๋น ์๋น์ ๋ ฅ๋(kWh/๋ช ) | |
---|---|---|
1 | 2022.0 | 10652.0798 |
2 | 2021.0 | 10330.0370 |
3 | 2020.0 | 9826.0000 |
4 | 2019.0 | 10039.0000 |
5 | 2018.0 | 10195.0000 |
... | ... | ... |
74 | 1949.0 | 0.0000 |
75 | 1948.0 | 0.0000 |
76 | 1947.0 | 0.0000 |
77 | 1946.0 | 0.0000 |
78 | 1945.0 | 0.0000 |
78 rows × 2 columns
In [16]:
df_poweruse_selected = df_poweruse_selected[(df_poweruse_selected['์ฐ๋'] >= 1955) & (df_poweruse_selected['์ฐ๋'] <= 2022)]
print(df_poweruse_selected)
์ฐ๋ ์ธ๊ตฌ1์ธ๋น ์๋น์ ๋ ฅ๋(kWh/๋ช
)
1 2022.0 10652.0798
2 2021.0 10330.0370
3 2020.0 9826.0000
4 2019.0 10039.0000
5 2018.0 10195.0000
.. ... ...
64 1959.0 140.0000
65 1958.0 173.0000
66 1957.0 139.0000
67 1956.0 0.0000
68 1955.0 0.0000
[68 rows x 2 columns]
In [17]:
### ๊ธฐ์ดํต๊ณํ์ธ : ์ด์์น ๋ฐ์ดํฐ ํ์ธํ๊ธฐ
df_poweruse_selected.describe
Out[17]:
<bound method NDFrame.describe of ์ฐ๋ ์ธ๊ตฌ1์ธ๋น ์๋น์ ๋ ฅ๋(kWh/๋ช
)
1 2022.0 10652.0798
2 2021.0 10330.0370
3 2020.0 9826.0000
4 2019.0 10039.0000
5 2018.0 10195.0000
.. ... ...
64 1959.0 140.0000
65 1958.0 173.0000
66 1957.0 139.0000
67 1956.0 0.0000
68 1955.0 0.0000
[68 rows x 2 columns]>
์ ๋ ฅ ๊ฐ๊ฒฉ¶
In [9]:
file_path = "./data/poweruse_total.csv"
df_powerprice_year = pd.read_csv(file_path, encoding='euc-kr')
df_powerprice_year
Out[9]:
์ฐ๋ | ๋ฐ์ ์ค๋น | Unnamed: 2 | Unnamed: 3 | Unnamed: 4 | Unnamed: 5 | ์ด๋ฐ์ ๋ | Unnamed: 7 | Unnamed: 8 | Unnamed: 9 | ... | Unnamed: 18 | ์ต๋์ ๋ ฅ(๋ฐ์ ๋จ)(MW) | ํ๊ท ์ ๋ ฅ(MW) | ๋ถํ์จ(%) | ์ด์ฉ์จ(%) | ์ดํจ์จ(%) | ํ๊ท ํ๋งค๋จ๊ฐ(์/kWh) | ๊ณ ๊ฐํธ์(์ฒํธ) | ์ข ์ ์์(๋ช ) | ์ธ๊ตฌ1์ธ๋น ์๋น์ ๋ ฅ๋(kWh/๋ช ) | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | NaN | ์๋ ฅ(MW) | ํ๋ ฅ(MW) | ์์๋ ฅ(MW) | ์๊ฐ์ฉ(MW) | ์ด๊ณ(MW) | ์๋ ฅ(GWh) | ํ๋ ฅ(GWh) | ์์๋ ฅ(GWh) | ์๊ฐ์ฉ(GWh) | ... | ์์์ฑ์ฅ๋ฅ (%) | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
1 | 2022.0 | 6513.123 | 80337.494 | 24650 | 5290.079 | 138194.755 | 7256.228 | 362201.282 | 176054.012 | 30650.791 | ... | 2.718 | 94509.0 | 67853.923 | 71.796 | 49.1002 | 41.65 | 120.507 | 24866.375 | 23563.0 | 10652.0798 |
2 | 2021.0 | 6541.335 | 80847.494 | 23250 | 5423.617 | 138482.028 | 6737.434 | 370750.105 | 158015.23 | 26152.804 | ... | 4.744 | 91141.0 | 65845.832 | 72.246 | 49.1310 | 41.53 | 108.110 | 24523.304 | 23288.0 | 10330.0370 |
3 | 2020.0 | 6505.768 | 80330.174 | 23250 | 4464.139 | 133391.583 | 7148.249 | 347157.194 | 160183.721 | 24783.489 | ... | -2.2 | 89091.0 | 62859.991 | 70.600 | 48.7000 | 41.14 | 109.800 | 24198.304 | 20970.0 | 9826.0000 |
4 | 2019.0 | 6508.103 | 80478.222 | 23250 | 4410.161 | 129091.579 | 6247.064 | 377844.247 | 145909.669 | 23407.545 | ... | -1.074 | 90314.0 | 64274.007 | 71.167 | 51.2810 | 40.70 | 108.658 | 23860.032 | 20531.0 | 10039.0000 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
74 | 1949.0 | 0 | 0 | 0 | 0 | 230.059 | 0 | 0 | 0 | 0 | ... | 0 | 115.0 | 74.763 | 65.000 | 0.0000 | 0.00 | 0.000 | 0.000 | 0.0 | 0.0000 |
75 | 1948.0 | 0 | 0 | 0 | 0 | 226.059 | 0 | 0 | 0 | 0 | ... | 0 | 122.0 | 79.007 | 65.000 | 0.0000 | 0.00 | 0.000 | 0.000 | 0.0 | 0.0000 |
76 | 1947.0 | 0 | 0 | 0 | 0 | 199.159 | 0 | 0 | 0 | 0 | ... | 0 | 146.0 | 94.607 | 65.000 | 0.0000 | 0.00 | 0.000 | 0.000 | 0.0 | 0.0000 |
77 | 1946.0 | 0 | 0 | 0 | 0 | 199.159 | 0 | 0 | 0 | 0 | ... | 0 | 119.0 | 77.183 | 65.000 | 0.0000 | 0.00 | 0.000 | 0.000 | 0.0 | 0.0000 |
78 | 1945.0 | 0 | 0 | 0 | 0 | 199.159 | 0 | 0 | 0 | 0 | ... | 0 | 115.0 | 81.202 | 71.000 | 0.0000 | 0.00 | 0.000 | 0.000 | 0.0 | 0.0000 |
79 rows × 28 columns
In [10]:
### ๊ฒฐ์ธก์น๊ฐ ์๋์ง ์ ๋ณด ํ์ธํ๊ธฐ
df_powerprice_year.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 79 entries, 0 to 78
Data columns (total 28 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 ์ฐ๋ 78 non-null float64
1 ๋ฐ์ ์ค๋น 79 non-null object
2 Unnamed: 2 79 non-null object
3 Unnamed: 3 79 non-null object
4 Unnamed: 4 79 non-null object
5 Unnamed: 5 79 non-null object
6 ์ด๋ฐ์ ๋ 79 non-null object
7 Unnamed: 7 79 non-null object
8 Unnamed: 8 79 non-null object
9 Unnamed: 9 79 non-null object
10 Unnamed: 10 79 non-null object
11 ์๋ด์ ๋ ฅ๋ 79 non-null object
12 Unnamed: 12 79 non-null object
13 ์์์ฉ์ ๋ ฅ๋(GWh) 78 non-null float64
14 ์ก์ ๋จ์ ๋ ฅ๋(GWh) 78 non-null float64
15 ์ก๋ฐฐ์ ์์ค๋ 79 non-null object
16 Unnamed: 16 79 non-null object
17 ํ๋งค์ ๋ ฅ๋ 79 non-null object
18 Unnamed: 18 79 non-null object
19 ์ต๋์ ๋ ฅ(๋ฐ์ ๋จ)(MW) 78 non-null float64
20 ํ๊ท ์ ๋ ฅ(MW) 78 non-null float64
21 ๋ถํ์จ(%) 78 non-null float64
22 ์ด์ฉ์จ(%) 78 non-null float64
23 ์ดํจ์จ(%) 78 non-null float64
24 ํ๊ท ํ๋งค๋จ๊ฐ(์/kWh) 78 non-null float64
25 ๊ณ ๊ฐํธ์(์ฒํธ) 78 non-null float64
26 ์ข
์
์์(๋ช
) 78 non-null float64
27 ์ธ๊ตฌ1์ธ๋น ์๋น์ ๋ ฅ๋(kWh/๋ช
) 78 non-null float64
dtypes: float64(12), object(16)
memory usage: 17.4+ KB
In [11]:
### ๊ธฐ์ดํต๊ณํ์ธ : ์ด์์น ๋ฐ์ดํฐ ํ์ธํ๊ธฐ
df_poweruse_year.describe
Out[11]:
<bound method NDFrame.describe of ์ฐ๋ ๋ฐ์ ์ค๋น Unnamed: 2 Unnamed: 3 Unnamed: 4 Unnamed: 5 ์ด๋ฐ์ ๋ \
0 NaN ์๋ ฅ(MW) ํ๋ ฅ(MW) ์์๋ ฅ(MW) ์๊ฐ์ฉ(MW) ์ด๊ณ(MW) ์๋ ฅ(GWh)
1 2022.0 6513.123 80337.494 24650 5290.079 138194.755 7256.228
2 2021.0 6541.335 80847.494 23250 5423.617 138482.028 6737.434
3 2020.0 6505.768 80330.174 23250 4464.139 133391.583 7148.249
4 2019.0 6508.103 80478.222 23250 4410.161 129091.579 6247.064
.. ... ... ... ... ... ... ...
74 1949.0 0 0 0 0 230.059 0
75 1948.0 0 0 0 0 226.059 0
76 1947.0 0 0 0 0 199.159 0
77 1946.0 0 0 0 0 199.159 0
78 1945.0 0 0 0 0 199.159 0
Unnamed: 7 Unnamed: 8 Unnamed: 9 ... Unnamed: 18 ์ต๋์ ๋ ฅ(๋ฐ์ ๋จ)(MW) \
0 ํ๋ ฅ(GWh) ์์๋ ฅ(GWh) ์๊ฐ์ฉ(GWh) ... ์์์ฑ์ฅ๋ฅ (%) NaN
1 362201.282 176054.012 30650.791 ... 2.718 94509.0
2 370750.105 158015.23 26152.804 ... 4.744 91141.0
3 347157.194 160183.721 24783.489 ... -2.2 89091.0
4 377844.247 145909.669 23407.545 ... -1.074 90314.0
.. ... ... ... ... ... ...
74 0 0 0 ... 0 115.0
75 0 0 0 ... 0 122.0
76 0 0 0 ... 0 146.0
77 0 0 0 ... 0 119.0
78 0 0 0 ... 0 115.0
ํ๊ท ์ ๋ ฅ(MW) ๋ถํ์จ(%) ์ด์ฉ์จ(%) ์ดํจ์จ(%) ํ๊ท ํ๋งค๋จ๊ฐ(์/kWh) ๊ณ ๊ฐํธ์(์ฒํธ) ์ข
์
์์(๋ช
) \
0 NaN NaN NaN NaN NaN NaN NaN
1 67853.923 71.796 49.1002 41.65 120.507 24866.375 23563.0
2 65845.832 72.246 49.1310 41.53 108.110 24523.304 23288.0
3 62859.991 70.600 48.7000 41.14 109.800 24198.304 20970.0
4 64274.007 71.167 51.2810 40.70 108.658 23860.032 20531.0
.. ... ... ... ... ... ... ...
74 74.763 65.000 0.0000 0.00 0.000 0.000 0.0
75 79.007 65.000 0.0000 0.00 0.000 0.000 0.0
76 94.607 65.000 0.0000 0.00 0.000 0.000 0.0
77 77.183 65.000 0.0000 0.00 0.000 0.000 0.0
78 81.202 71.000 0.0000 0.00 0.000 0.000 0.0
์ธ๊ตฌ1์ธ๋น ์๋น์ ๋ ฅ๋(kWh/๋ช
)
0 NaN
1 10652.0798
2 10330.0370
3 9826.0000
4 10039.0000
.. ...
74 0.0000
75 0.0000
76 0.0000
77 0.0000
78 0.0000
[79 rows x 28 columns]>
In [12]:
# ํ์ํ ์ด๋ง ์ถ์ถ
df_powerprice_year_selected = df_powerprice_year[['์ฐ๋', 'ํ๊ท ํ๋งค๋จ๊ฐ(์/kWh)']].copy()
df_powerprice_year_selected
Out[12]:
์ฐ๋ | ํ๊ท ํ๋งค๋จ๊ฐ(์/kWh) | |
---|---|---|
0 | NaN | NaN |
1 | 2022.0 | 120.507 |
2 | 2021.0 | 108.110 |
3 | 2020.0 | 109.800 |
4 | 2019.0 | 108.658 |
... | ... | ... |
74 | 1949.0 | 0.000 |
75 | 1948.0 | 0.000 |
76 | 1947.0 | 0.000 |
77 | 1946.0 | 0.000 |
78 | 1945.0 | 0.000 |
79 rows × 2 columns
In [13]:
# 'ํ๊ท ํ๋งค๋จ๊ฐ(์/kWh)'์ด 0์ด ์๋ ํ ์ ํ
df_powerprice_year_selected_cleaned = df_powerprice_year_selected[df_powerprice_year_selected['ํ๊ท ํ๋งค๋จ๊ฐ(์/kWh)'] != 0]
# ๋ณ๊ฒฝ๋ ๋ฐ์ดํฐํ๋ ์ ํ์ธ
print(df_powerprice_year_selected_cleaned)
์ฐ๋ ํ๊ท ํ๋งค๋จ๊ฐ(์/kWh)
0 NaN NaN
1 2022.0 120.507
2 2021.0 108.110
3 2020.0 109.800
4 2019.0 108.658
.. ... ...
64 1959.0 8.000
65 1958.0 8.000
66 1957.0 8.000
67 1956.0 3.000
68 1955.0 3.000
[69 rows x 2 columns]
In [14]:
# ์ฒซ ํ ์ ๊ฑฐ
df_powerprice_year_selected_cleaned = df_powerprice_year_selected_cleaned.drop(0)
df_powerprice_year_selected_cleaned
Out[14]:
์ฐ๋ | ํ๊ท ํ๋งค๋จ๊ฐ(์/kWh) | |
---|---|---|
1 | 2022.0 | 120.507 |
2 | 2021.0 | 108.110 |
3 | 2020.0 | 109.800 |
4 | 2019.0 | 108.658 |
5 | 2018.0 | 108.748 |
... | ... | ... |
64 | 1959.0 | 8.000 |
65 | 1958.0 | 8.000 |
66 | 1957.0 | 8.000 |
67 | 1956.0 | 3.000 |
68 | 1955.0 | 3.000 |
68 rows × 2 columns
In [15]:
# ๋ฐ์ดํฐ ํ์
๋ณ๊ฒฝ (์ฐ๋๋ ์ ์, ์ธ๊ตฌ1์ธ๋น ์๋น์ ๋ ฅ๋์ ์ค์)
df_powerprice_year_selected_cleaned['์ฐ๋'] = df_powerprice_year_selected_cleaned['์ฐ๋'].astype(int)
df_powerprice_year_selected_cleaned['ํ๊ท ํ๋งค๋จ๊ฐ(์/kWh)'] = pd.to_numeric(df_powerprice_year_selected_cleaned['ํ๊ท ํ๋งค๋จ๊ฐ(์/kWh)'])
df_powerprice_year_selected_cleaned
Out[15]:
์ฐ๋ | ํ๊ท ํ๋งค๋จ๊ฐ(์/kWh) | |
---|---|---|
1 | 2022 | 120.507 |
2 | 2021 | 108.110 |
3 | 2020 | 109.800 |
4 | 2019 | 108.658 |
5 | 2018 | 108.748 |
... | ... | ... |
64 | 1959 | 8.000 |
65 | 1958 | 8.000 |
66 | 1957 | 8.000 |
67 | 1956 | 3.000 |
68 | 1955 | 3.000 |
68 rows × 2 columns
In [18]:
import numpy as np
In [19]:
# ๋ฐ์ดํฐํ๋ ์์์ describe ๋ฉ์๋๋ฅผ ํธ์ถํ์ฌ ๊ธฐ์ด ํต๊ณ ์ ๋ณด๋ฅผ ํ์ธ
description_poweruse = df_poweruse_selected.describe()
In [23]:
# 2015๋
์ ์ฌ์ฉํ ์ ๋ ฅ๋ ๊ณ์ฐ
power_consumption_2015 = df_poweruse_selected.loc[df_poweruse_selected['์ฐ๋'] == 2015, '์ธ๊ตฌ1์ธ๋น ์๋น์ ๋ ฅ๋(kWh/๋ช
)'].values[0]
power_consumption_2015
Out[23]:
9555.177
In [25]:
# ์ ๋ ฅํ๋งค๋จ๊ฐ ๋ฐ์ดํฐํ๋ ์์์ 2015๋
์ ํ๊ท ์ ๋ ฅํ๋งค๋จ๊ฐ ์ถ์ถ
average_price_2015 = df_powerprice_year_selected_cleaned.loc[df_powerprice_year_selected_cleaned['์ฐ๋'] == 2015, 'ํ๊ท ํ๋งค๋จ๊ฐ(์/kWh)'].values[0]
average_price_2015
Out[25]:
111.575
In [28]:
# 2015๋
์ ์ฌ์ฉํ ์ ๋ ฅ๋ * ํ๊ท ์ ๋ ฅํ๋งค๋จ๊ฐ ๊ณ์ฐ
total_cost_2015 = power_consumption_2015 * average_price_2015
total_cost_2015
Out[28]:
1066118.873775
In [29]:
# ์ ๋ ฅํ๋งค๋จ๊ฐ ๋ฐ์ดํฐํ๋ ์์์ 2022๋
์ ํ๊ท ์ ๋ ฅํ๋งค๋จ๊ฐ ์ถ์ถ
average_price_2022 = df_powerprice_year_selected_cleaned.loc[df_powerprice_year_selected_cleaned['์ฐ๋'] == 2022, 'ํ๊ท ํ๋งค๋จ๊ฐ(์/kWh)'].values[0]
average_price_2022
Out[29]:
120.507
In [30]:
# 2015๋
์ ์ฌ์ฉํ ์ ๋ ฅ๋ * ํ๊ท ์ ๋ ฅํ๋งค๋จ๊ฐ ๊ณ์ฐ
total_cost_2015 = power_consumption_2015 * average_price_2015
# 2022๋
ํ๊ท ์ ๋ ฅํ๋งค๋จ๊ฐ
average_price_2022 = df_powerprice_year_selected_cleaned.loc[df_powerprice_year_selected_cleaned['์ฐ๋'] == 2022, 'ํ๊ท ํ๋งค๋จ๊ฐ(์/kWh)'].values[0]
# x ๊ณ์ฐ
x = total_cost_2015 / average_price_2022
print(f"x์ ๊ฐ: {x}")
x์ ๊ฐ: 8846.945602952524
In [32]:
# 2015๋
์ ์ฌ์ฉํ ์ ๋ ฅ๋ ๊ณ์ฐ
power_consumption_2022 = df_poweruse_selected.loc[df_poweruse_selected['์ฐ๋'] == 2022, '์ธ๊ตฌ1์ธ๋น ์๋น์ ๋ ฅ๋(kWh/๋ช
)'].values[0]
power_consumption_2022
Out[32]:
10652.0798
In [35]:
# ์ ๊ธฐ์ธ ์ผ๋ง ์ฌ๋๋ค!
# 2015๋
ํ๊ท ์ ๋ ฅํ๋งค๋จ๊ฐ
average_price_2015 = df_powerprice_year_selected_cleaned.loc[df_powerprice_year_selected_cleaned['์ฐ๋'] == 2015, 'ํ๊ท ํ๋งค๋จ๊ฐ(์/kWh)'].values[0]
# 2022๋
ํ๊ท ์ ๋ ฅํ๋งค๋จ๊ฐ
average_price_2022 = df_powerprice_year_selected_cleaned.loc[df_powerprice_year_selected_cleaned['์ฐ๋'] == 2022, 'ํ๊ท ํ๋งค๋จ๊ฐ(์/kWh)'].values[0]
# ์ฐจ์ด ๊ณ์ฐ
price_difference = average_price_2015 - average_price_2022
print(f"2015๋
๊ณผ 2022๋
์ ํ๊ท ํ๋งค๋จ๊ฐ ์ฐจ์ด: {price_difference} ์/kWh")
2015๋
๊ณผ 2022๋
์ ํ๊ท ํ๋งค๋จ๊ฐ ์ฐจ์ด: -8.932000000000002 ์/kWh
In [36]:
# ์ฌ์ฉ๋ ์ผ๋ง ์ฌ๋๋ค!
# 2022๋
์ฌ์ฉ๋
usage_2022 = df_poweruse_selected.loc[df_poweruse_selected['์ฐ๋'] == 2022, '์ธ๊ตฌ1์ธ๋น ์๋น์ ๋ ฅ๋(kWh/๋ช
)'].values[0]
# 2015๋
์ฌ์ฉ๋
usage_2015 = df_poweruse_selected.loc[df_poweruse_selected['์ฐ๋'] == 2015, '์ธ๊ตฌ1์ธ๋น ์๋น์ ๋ ฅ๋(kWh/๋ช
)'].values[0]
# ์ฐจ์ด ๊ณ์ฐ
usage_difference = usage_2022 - usage_2015
print(f"2015๋
๊ณผ 2022๋
์ ์ฌ์ฉ๋ ์ฐจ์ด: {usage_difference} kWh/๋ช
")
2015๋
๊ณผ 2022๋
์ ์ฌ์ฉ๋ ์ฐจ์ด: 1096.9027999999998 kWh/๋ช
In [39]:
# ๊ฐ์์(2015)์ ์ ๋ ฅ์ ์ฌ์ฉํ๋ ค๋ฉด?
# x ๋งํผ ๋ ๋น์ธ๊ฒ ์ง์ถํด์ผ ํ๋ค!
# 2015๋
์ ๋ ฅ ๋น์ฉ
total_cost_2015 = power_consumption_2015 * average_price_2015
# 2022๋
์ ๋ ฅ ๋น์ฉ
total_cost_2022 = power_consumption_2015 * average_price_2022
# ๋ ๋น์ฉ์ ์ฐจ์ด ๊ณ์ฐ
cost_difference = total_cost_2022 - total_cost_2015
print(f"2015๋
์ ๋ ฅ ๋น์ฉ: {total_cost_2015} ์")
print(f"2022๋
์ ๋ ฅ ๋น์ฉ: {total_cost_2022} ์")
print(f"๋ ๋น์ฉ์ ์ฐจ์ด๋งํผ ๋ ์จ์ผ ํฉ๋๋ค!: {cost_difference} ์")
2015๋
์ ๋ ฅ ๋น์ฉ: 1066118.873775 ์
2022๋
์ ๋ ฅ ๋น์ฉ: 1151465.714739 ์
๋ ๋น์ฉ์ ์ฐจ์ด๋งํผ ๋ ์จ์ผ ํฉ๋๋ค!: 85346.84096399997 ์
In [97]:
# 2022๋
์ฌ์ฉ๋ ๊ธฐ์ค
# 2022๋
์ฌ์ฉ๋ ๊ธฐ์ค์ผ๋ก ์
๋ ฅ๋
๋์ ์ ๊ธฐ์ธ๋ฅผ ๊ณฑํ๋ฉด?
def calculate_power_cost_difference(year):
# ์
๋ ฅ๊ฐ์ 1955๋
๋ถํฐ 2022๋
์ฌ์ด์ ๊ฐ์ผ๋ก ์ ํ
if year < 1955 or year > 2022:
print("1955๋
๊ณผ 2022๋
์ฌ์ด์ ๊ฐ๋ง ์
๋ ฅํ ์ ์์ต๋๋ค.")
return
# ์
๋ ฅ๋ฐ์ ์ฐ๋์ ์ ๋ ฅ๋
usage = df_poweruse_selected.loc[df_poweruse_selected['์ฐ๋'] == year, '์ธ๊ตฌ1์ธ๋น ์๋น์ ๋ ฅ๋(kWh/๋ช
)'].values[0]
# 2022๋
์ ์ ๋ ฅ ๋น์ฉ
total_cost_2022 = power_consumption_2022 * average_price_2022
# ์
๋ ฅ๋ฐ์ ์ฐ๋์ ์ ๋ ฅํ๋งค๋จ๊ฐ
average_price_year = df_powerprice_year_selected_cleaned.loc[df_powerprice_year_selected_cleaned['์ฐ๋'] == year, 'ํ๊ท ํ๋งค๋จ๊ฐ(์/kWh)'].values[0]
# ์
๋ ฅ๋ฐ์ ์ฐ๋์ ์ ๋ ฅ ๋น์ฉ
total_cost_year = power_consumption_2022 * average_price_year
# ๋ ๋น์ฉ์ ์ฐจ์ด ๊ณ์ฐ
cost_difference = total_cost_year - total_cost_2022
# ๋น์ฉ ์ฐจ์ด์ ์ ๋๊ฐ ๊ณ์ฐ ๋ฐ ์์ซ์ ์ฒซ์งธ ์๋ฆฌ์์ ๋ฐ์ฌ๋ฆผ
absolute_cost_difference = round(abs(cost_difference))
# ์์ซ์ ์ฒซ์งธ ์๋ฆฌ์์ ๋ฐ์ฌ๋ฆผํ์ฌ ์ถ๋ ฅ
total_cost_2022 = round(total_cost_2022)
total_cost_year = round(total_cost_year)
print(f"2022๋
์ ๋ ฅ ๋น์ฉ: {total_cost_2022} ์")
print(f"{year}๋
์ ๋ ฅ ๋น์ฉ: {total_cost_year} ์")
if cost_difference < 0:
print(f"2022๋
๊ณผ {year}๋
์ ์ ๋ ฅ ๋น์ฉ ์ฐจ์ด: {year}๋
์ ๋นํด 2022๋
์ ์ ๊ธฐ์ธ๊ฐ {absolute_cost_difference}์ ์์นํ์์ต๋๋ค.")
else:
print(f"2022๋
๊ณผ {year}๋
์ ์ ๋ ฅ ๋น์ฉ ์ฐจ์ด: {year}๋
์ ๋นํด 2022๋
์ ์ ๊ธฐ์ธ๊ฐ {absolute_cost_difference}์ ํ๋ฝํ์์ต๋๋ค.")
# ํจ์ ํธ์ถ ์์
calculate_power_cost_difference(2021)
2022๋
์ ๋ ฅ ๋น์ฉ: 1283650 ์
2021๋
์ ๋ ฅ ๋น์ฉ: 1151596 ์
2022๋
๊ณผ 2021๋
์ ์ ๋ ฅ ๋น์ฉ ์ฐจ์ด: 2021๋
์ ๋นํด 2022๋
์ ์ ๊ธฐ์ธ๊ฐ 132054์ ์์นํ์์ต๋๋ค.
In [88]:
calculate_power_cost_difference(2011)
2022๋
์ ๋ ฅ ๋น์ฉ: 1283650 ์
2011๋
์ ๋ ฅ ๋น์ฉ: 951444 ์
2022๋
๊ณผ 2011๋
์ ์ ๋ ฅ ๋น์ฉ ์ฐจ์ด: ์ ๊ธฐ์ธ๊ฐ 332206 ์ ์์นํ์์ต๋๋ค.
In [37]:
#2015๋
์๋ ์ด๋งํผ ์ผ๋ค!
# 2015๋
์ ๋ ฅ ๋น์ฉ
total_cost_2015 = power_consumption_2015 * average_price_2015
print(f"2015๋
์ ๋ ฅ ๋น์ฉ: {total_cost_2015} ์")
2015๋
์ ๋ ฅ ๋น์ฉ: 1066118.873775 ์
In [38]:
#2022๋
์๋ ์ด๋งํผ ์ผ๋ค!
# 2022๋
์ ๋ ฅ ๋น์ฉ
total_cost_2022 = power_consumption_2022 * average_price_2022
print(f"2022๋
์ ๋ ฅ ๋น์ฉ: {total_cost_2022} ์")
2015๋
์ ๋ ฅ ๋น์ฉ: 1283650.1804586 ์
In [41]:
# ์ด๋งํผ ๋ ๋ง์ด ๋ด๊ณ ์๋ค!!
# 2015๋
์ ๋ ฅ ๋น์ฉ
total_cost_2015 = power_consumption_2015 * average_price_2015
# 2022๋
์ ๋ ฅ ๋น์ฉ
total_cost_2022 = power_consumption_2022 * average_price_2022
# ๋ ๋น์ฉ์ ์ฐจ์ด ๊ณ์ฐ
cost_difference = total_cost_2022 - total_cost_2015
print(f"2015๋
์ ๋ ฅ ๋น์ฉ: {total_cost_2015} ์")
print(f"2022๋
์ ๋ ฅ ๋น์ฉ: {total_cost_2022} ์")
print(f"์ด๋งํผ ๋น์ธ์ก์ต๋๋ค!: {cost_difference} ์")
2015๋
์ ๋ ฅ ๋น์ฉ: 1066118.873775 ์
2022๋
์ ๋ ฅ ๋น์ฉ: 1283650.1804586 ์
์ด๋งํผ ๋น์ธ์ก์ต๋๋ค!: 217531.30668359995 ์
In [98]:
# 2022๋
์ฌ์ฉ๋, ์ ๊ธฐ์ธ ๊ธฐ์ค
# 2022๋
์ฌ์ฉ๋ * ์ ๊ธฐ์ธ - ์
๋ ฅ๋
๋ ์ฌ์ฉ๋ * ์ ๊ธฐ์ธ
def calculate_power_total_cost_difference(year):
# ์
๋ ฅ๊ฐ์ 1955๋
๋ถํฐ 2022๋
์ฌ์ด์ ๊ฐ์ผ๋ก ์ ํ
if year < 1955 or year > 2022:
print("1955๋
๊ณผ 2022๋
์ฌ์ด์ ๊ฐ๋ง ์
๋ ฅํ ์ ์์ต๋๋ค.")
return
# 2022๋
์ ์ ๋ ฅ ๋น์ฉ
total_cost_2022 = power_consumption_2022 * average_price_2022
# ์
๋ ฅ๋ฐ์ ์ฐ๋์ ์ ๋ ฅ๋
usage_year = df_poweruse_selected.loc[df_poweruse_selected['์ฐ๋'] == year, '์ธ๊ตฌ1์ธ๋น ์๋น์ ๋ ฅ๋(kWh/๋ช
)'].values[0]
# ์
๋ ฅ๋ฐ์ ์ฐ๋์ ์ ๋ ฅํ๋งค๋จ๊ฐ
average_price_year = df_powerprice_year_selected_cleaned.loc[df_powerprice_year_selected_cleaned['์ฐ๋'] == year, 'ํ๊ท ํ๋งค๋จ๊ฐ(์/kWh)'].values[0]
# ์
๋ ฅ๋ฐ์ ์ฐ๋์ ์ ๋ ฅ ๋น์ฉ
total_cost_year = usage_year * average_price_year
# ๋ ๋น์ฉ์ ์ฐจ์ด ๊ณ์ฐ
cost_difference = total_cost_2022 - total_cost_year
# ๋น์ฉ ์ฐจ์ด์ ์ ๋๊ฐ ๊ณ์ฐ ๋ฐ ์์ซ์ ์ฒซ์งธ ์๋ฆฌ์์ ๋ฐ์ฌ๋ฆผ
absolute_cost_difference = round(abs(cost_difference))
# ์์ซ์ ์ฒซ์งธ ์๋ฆฌ์์ ๋ฐ์ฌ๋ฆผํ์ฌ ์ถ๋ ฅ
total_cost_2022 = round(total_cost_2022)
total_cost_year = round(total_cost_year)
print(f"2022๋
์ ๋ ฅ์ธ ๋น์ฉ: {total_cost_2022} ์")
print(f"{year}๋
์ ๋ ฅ์ธ ๋น์ฉ: {total_cost_year} ์")
if cost_difference < 0:
print(f"2022๋
๊ณผ {year}๋
์ ์ ๋ ฅ์ธ ๋น์ฉ ์ฐจ์ด: {year}๋
์ ๋นํด 2022๋
์ ์ ๊ธฐ๋ฃ๋ฅผ {absolute_cost_difference}์ ๋ ์ง์ถํ๊ณ ์์ต๋๋ค.")
else:
print(f"2022๋
๊ณผ {year}๋
์ ์ ๋ ฅ์ธ ๋น์ฉ ์ฐจ์ด: {year}๋
์ ๋นํด 2022๋
์ ์ ๊ธฐ๋ฃ๋ฅผ {absolute_cost_difference}์ ๋ ์ง์ถํ๊ณ ์์ต๋๋ค.")
# ํจ์ ํธ์ถ ์์
calculate_power_total_cost_difference(2021)
2022๋
์ ๋ ฅ์ธ ๋น์ฉ: 1283650 ์
2021๋
์ ๋ ฅ์ธ ๋น์ฉ: 1116780 ์
2022๋
๊ณผ 2021๋
์ ์ ๋ ฅ์ธ ๋น์ฉ ์ฐจ์ด: 2021๋
์ ๋นํด 2022๋
์ ์ ๊ธฐ๋ฃ๋ฅผ 166870์ ๋ ์ง์ถํ๊ณ ์์ต๋๋ค.
1์ธ๋น ์ ๋ ฅ์๋น๋ ์์ธก¶
In [113]:
import numpy as np
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error
import matplotlib.pyplot as plt
# ํ๊ธ ํฐํธ ์ค์
from matplotlib import font_manager, rc
plt.rc("font", family = "Malgun Gothic")
# ๋ฐ์ดํฐ ์ค๋น
years = df_poweruse_selected['์ฐ๋'].values.reshape(-1, 1)
consumption = df_poweruse_selected['์ธ๊ตฌ1์ธ๋น ์๋น์ ๋ ฅ๋(kWh/๋ช
)'].values
# ์ ํ ํ๊ท ๋ชจ๋ธ ํ์ต
model = LinearRegression()
model.fit(years, consumption)
# ํฅํ ์ฐ๋ ์์ฑ (2023๋
๋ถํฐ 2070๋
๊น์ง)
future_years = np.arange(2023, 2071).reshape(-1, 1)
# ํฅํ ์ฐ๋์ ๋ํ ์์ธก
predicted_consumption = model.predict(future_years)
predicted_consumption
Out[113]:
array([ 9773.25567785, 9951.63324879, 10130.01081972, 10308.38839066,
10486.7659616 , 10665.14353253, 10843.52110347, 11021.89867441,
11200.27624534, 11378.65381628, 11557.03138721, 11735.40895815,
11913.78652909, 12092.16410002, 12270.54167096, 12448.91924189,
12627.29681283, 12805.67438377, 12984.0519547 , 13162.42952564,
13340.80709657, 13519.18466751, 13697.56223845, 13875.93980938,
14054.31738032, 14232.69495125, 14411.07252219, 14589.45009313,
14767.82766406, 14946.205235 , 15124.58280593, 15302.96037687,
15481.33794781, 15659.71551874, 15838.09308968, 16016.47066061,
16194.84823155, 16373.22580249, 16551.60337342, 16729.98094436,
16908.35851529, 17086.73608623, 17265.11365717, 17443.4912281 ,
17621.86879904, 17800.24636997, 17978.62394091, 18157.00151185])
In [112]:
# ์์ธก ๊ฒฐ๊ณผ ์๊ฐํ
plt.figure(figsize=(10, 6))
plt.scatter(years, consumption, label='์ค์ ๋ฐ์ดํฐ')
plt.plot(future_years, predicted_consumption, label='์์ธก ๊ฒฐ๊ณผ', color='red', linestyle='--')
plt.xlabel('์ฐ๋')
plt.ylabel('์ธ๊ตฌ1์ธ๋น ์๋น์ ๋ ฅ๋(kWh/๋ช
)')
plt.title('์ธ๊ตฌ1์ธ๋น ์๋น์ ๋ ฅ๋ ์์ธก')
plt.legend()
plt.show()
In [132]:
import numpy as np
from sklearn.linear_model import LinearRegression
def calculate_consumption_increase_percentage(year):
# ์
๋ ฅ๊ฐ์ 1955๋
๋ถํฐ 2070๋
์ฌ์ด์ ๊ฐ์ผ๋ก ์ ํ
if year < 1955 or year > 2070:
print("1955๋
๊ณผ 2070๋
์ฌ์ด์ ๊ฐ๋ง ์
๋ ฅํ ์ ์์ต๋๋ค.")
return
# ์
๋ ฅ๋ฐ์ ์ฐ๋์ ๋ํ ์๋น์ ๋ ฅ๋ ์์ธก
predicted_consumption = model.predict(np.array([[year]]))[0]
# 2022๋
์ ์๋น์ ๋ ฅ๋
consumption_2022 = model.predict(np.array([[2022]]))[0]
# ์๋น์ ๋ ฅ๋ ์์น์ก ๊ณ์ฐ
increase_amount = predicted_consumption - consumption_2022
# ์๋น์ ๋ ฅ๋ ์์น๋ฅ ๊ณ์ฐ
increase_percentage = (increase_amount / consumption_2022) * 100
print(f"2022๋
์ ์๋น์ ๋ ฅ๋์ {consumption_2022:.2f} kWh/๋ช
์ด๊ณ , {year}๋
์ ์์ ์๋น์ ๋ ฅ๋์ {predicted_consumption:.2f} kWh/๋ช
์
๋๋ค.")
print(f"{year}๋
์ ์์ ์๋น์ ๋ ฅ๋์ 2022๋
๋๋น {increase_percentage:.2f}% ์์นํฉ๋๋ค.")
# ํจ์ ํธ์ถ ์์
calculate_consumption_increase_percentage(2030)
2022๋
์ ์๋น์ ๋ ฅ๋์ 9594.88 kWh/๋ช
์ด๊ณ , 2030๋
์ ์์ ์๋น์ ๋ ฅ๋์ 11021.90 kWh/๋ช
์
๋๋ค.
2030๋
์ ์์ ์๋น์ ๋ ฅ๋์ 2022๋
๋๋น 14.87% ์์นํฉ๋๋ค.
In [ ]:
์ ๊ธฐ์ธ ์์ธก¶
In [109]:
import numpy as np
import pandas as pd
from sklearn.linear_model import LinearRegression
import matplotlib.pyplot as plt
# ํ๊ธ ํฐํธ ์ค์
from matplotlib import font_manager, rc
plt.rc("font", family="Malgun Gothic")
# ์ฃผ์ด์ง ๋ฐ์ดํฐ
years_existing = df_powerprice_year_selected_cleaned['์ฐ๋'].values.reshape(-1, 1)
average_prices_existing = df_powerprice_year_selected_cleaned['ํ๊ท ํ๋งค๋จ๊ฐ(์/kWh)'].values
# ์ ํ ํ๊ท ๋ชจ๋ธ ํ์ต
model_existing = LinearRegression()
model_existing.fit(years_existing, average_prices_existing)
# ํฅํ ์ฐ๋ ์์ฑ (2023๋
๋ถํฐ 2070๋
๊น์ง)
future_years = np.arange(2023, 2071).reshape(-1, 1)
# ํฅํ ์ฐ๋์ ๋ํ ์์ธก
predicted_average_prices_existing = model_existing.predict(years_existing)
predicted_average_prices_future = model_existing.predict(future_years)
predicted_average_prices_future
Out[109]:
array([116.4880079 , 118.31886107, 120.14971424, 121.98056741,
123.81142058, 125.64227375, 127.47312692, 129.30398009,
131.13483326, 132.96568643, 134.7965396 , 136.62739277,
138.45824594, 140.28909911, 142.11995228, 143.95080545,
145.78165863, 147.6125118 , 149.44336497, 151.27421814,
153.10507131, 154.93592448, 156.76677765, 158.59763082,
160.42848399, 162.25933716, 164.09019033, 165.9210435 ,
167.75189667, 169.58274984, 171.41360301, 173.24445618,
175.07530935, 176.90616252, 178.73701569, 180.56786886,
182.39872203, 184.2295752 , 186.06042837, 187.89128154,
189.72213471, 191.55298788, 193.38384105, 195.21469422,
197.04554739, 198.87640056, 200.70725373, 202.5381069 ])
In [108]:
# ์๊ฐํ
plt.figure(figsize=(12, 6))
# ์ค์ ๋ฐ์ดํฐ ๊ทธ๋ํ
plt.scatter(years_existing, average_prices_existing, label='์ค์ ๋ฐ์ดํฐ', color='blue')
# ํ๊ท๋ถ์ ๊ฒฐ๊ณผ ๊ทธ๋ํ
plt.plot(years_existing, predicted_average_prices_existing, label='ํ๊ท๋ถ์ ๊ฒฐ๊ณผ (๊ณผ๊ฑฐ)', color='green', linestyle='--')
# ๋ฏธ๋ ์์ธก ๊ทธ๋ํ
plt.plot(future_years, predicted_average_prices_future, label='ํ๊ท๋ถ์ ๊ฒฐ๊ณผ (๋ฏธ๋)', color='red', linestyle='--')
plt.xlabel('์ฐ๋')
plt.ylabel('ํ๊ท ํ๋งค๋จ๊ฐ(์/kWh)')
plt.title('ํ๊ท ํ๋งค๋จ๊ฐ ์์ธก')
plt.legend()
plt.grid(True)
plt.show()
In [133]:
# ์ ๊ธฐ์ธ ๋ฏธ๋ ์์ธก ํจ์
import numpy as np
from sklearn.linear_model import LinearRegression
def calculate_percentage_increase(year):
# ์
๋ ฅ๊ฐ์ 1955๋
๋ถํฐ 2022๋
์ฌ์ด์ ๊ฐ์ผ๋ก ์ ํ
if year < 1955 or year > 2070:
print("1955๋
๊ณผ 2070๋
์ฌ์ด์ ๊ฐ๋ง ์
๋ ฅํ ์ ์์ต๋๋ค.")
return
# ์
๋ ฅ๋ฐ์ ์ฐ๋์ ๋ํ ์ ๊ธฐ์ธ ์์ธก
predicted_price = model_existing.predict(np.array([[year]]))[0]
# 2022๋
์ ์ ๊ธฐ์ธ
price_2022 = model_existing.predict(np.array([[2022]]))[0]
# ์ ๊ธฐ์ธ ์์น์ก ๊ณ์ฐ
increase_amount = predicted_price - price_2022
# ์ ๊ธฐ์ธ ์์น๋ฅ ๊ณ์ฐ
increase_percentage = (increase_amount / price_2022) * 100
print(f"2022๋
์ ์ ๊ธฐ์ธ๋ {price_2022:.2f} ์์ด๊ณ , {year}๋
์ ์์ ์ ๊ธฐ์ธ๋ {predicted_price:.2f} ์์
๋๋ค.")
print(f"{year}๋
์ ์์ ์ ๊ธฐ์ธ๋ 2022๋
๋๋น {increase_percentage:.2f}% ์์นํฉ๋๋ค.")
# ํจ์ ํธ์ถ ์์
calculate_percentage_increase(2030)
2022๋
์ ์ ๊ธฐ์ธ๋ 114.66 ์์ด๊ณ , 2030๋
์ ์์ ์ ๊ธฐ์ธ๋ 129.30 ์์
๋๋ค.
2030๋
์ ์์ ์ ๊ธฐ์ธ๋ 2022๋
๋๋น 12.77% ์์นํฉ๋๋ค.
In [ ]:
๋ฏธ๋์ ์๋น์ ๋ ฅ๋ * ์ ๊ธฐ์ธ¶
In [134]:
import numpy as np
from sklearn.linear_model import LinearRegression
# 2022๋
์ ์ ๊ธฐ์ธ ๋ฐ ์๋น์ ๋ ฅ๋ ์์ธก
price_2022 = model_existing.predict(np.array([[2022]]))[0]
consumption_2022 = model.predict(np.array([[2022]]))[0]
power_cost_2022 = price_2022 * consumption_2022
def calculate_total_power_cost(year):
# ์
๋ ฅ๊ฐ์ 1955๋
๋ถํฐ 2070๋
์ฌ์ด์ ๊ฐ์ผ๋ก ์ ํ
if year < 1955 or year > 2070:
print("1955๋
๊ณผ 2070๋
์ฌ์ด์ ๊ฐ๋ง ์
๋ ฅํ ์ ์์ต๋๋ค.")
return
# ์
๋ ฅ๋ฐ์ ์ฐ๋์ ๋ํ ์ ๊ธฐ์ธ ์์ธก
predicted_price = model_existing.predict(np.array([[year]]))[0]
# ์
๋ ฅ๋ฐ์ ์ฐ๋์ ๋ํ ์๋น์ ๋ ฅ๋ ์์ธก
predicted_consumption = model.predict(np.array([[year]]))[0]
# ์ ๊ธฐ์ธ * ์๋น์ ๋ ฅ๋์ผ๋ก ์ ๊ธฐ๋ฃ ๊ณ์ฐ
total_power_cost = predicted_price * predicted_consumption
print(f"{year}๋
์ ์์ ์ ๊ธฐ์ธ๋ {predicted_price:.2f} ์์ด๊ณ , ์์ ์๋น์ ๋ ฅ๋์ {predicted_consumption:.2f} kWh/๋ช
์
๋๋ค.")
print(f"{year}๋
์ ์์ ์ ๊ธฐ๋ฃ๋ ์ฝ {total_power_cost:.2f} ์์
๋๋ค.")
print(f"2022๋
์ ์ ๊ธฐ์ธ๋ {price_2022:.2f} ์์ด๊ณ , ์๋น์ ๋ ฅ๋์ {consumption_2022:.2f} kWh/๋ช
์
๋๋ค.")
print(f"2022๋
์ ์ ๊ธฐ๋ฃ๋ ์ฝ {power_cost_2022:.2f} ์์
๋๋ค.")
# ์์น๋ฅ ๊ณ์ฐ
increase_percentage = ((total_power_cost - power_cost_2022) / power_cost_2022) * 100
print(f"{year}๋
์ ์์ ์ ๊ธฐ๋ฃ๋ 2022๋
๋์ ์ ๊ธฐ๋ฃ์ ๋นํด {increase_percentage:.2f}% ์์นํฉ๋๋ค.")
return total_power_cost
# ํจ์ ํธ์ถ ์์
calculate_total_power_cost(2060)
2060๋
์ ์์ ์ ๊ธฐ์ธ๋ 184.23 ์์ด๊ณ , ์์ ์๋น์ ๋ ฅ๋์ 16373.23 kWh/๋ช
์
๋๋ค.
2060๋
์ ์์ ์ ๊ธฐ๋ฃ๋ ์ฝ 3016432.43 ์์
๋๋ค.
2022๋
์ ์ ๊ธฐ์ธ๋ 114.66 ์์ด๊ณ , ์๋น์ ๋ ฅ๋์ 9594.88 kWh/๋ช
์
๋๋ค.
2022๋
์ ์ ๊ธฐ๋ฃ๋ ์ฝ 1100121.42 ์์
๋๋ค.
2060๋
์ ์์ ์ ๊ธฐ๋ฃ๋ 2022๋
๋์ ์ ๊ธฐ๋ฃ์ ๋นํด 174.19% ์์นํฉ๋๋ค.
Out[134]:
3016432.434236781
In [ ]:
728x90
๋ฐ์ํ