Last active
August 7, 2018 03:23
-
-
Save yeondudad/e88aa4546f03f8a87b36ebb1182cbd38 to your computer and use it in GitHub Desktop.
전기요금 누진제 완화 전/후 비교(주택용 저압)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import division | |
import functools | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
def calculate_charge(kWh, step1=200, step2=400, step3=1000): | |
if kWh <= step1: | |
minimum_charge = 910 | |
unit_charge = 93.3 | |
total_charge = minimum_charge + (unit_charge * kWh) | |
elif kWh <= step2: | |
minimum_charge = 1600 | |
unit_charge1 = 93.3 | |
unit_charge2 = 187.9 | |
total_charge = minimum_charge + (unit_charge1 * step1) + (unit_charge2 * (kWh - step1)) | |
elif kWh <= step3: | |
minimum_charge = 7300 | |
unit_charge1 = 93.3 | |
unit_charge2 = 187.9 | |
unit_charge3 = 280.6 | |
total_charge = minimum_charge + (unit_charge1 * step1) + (unit_charge2 * (step2 - step1)) + (unit_charge3 * (kWh - step2)) | |
else: | |
minimum_charge = 7300 | |
unit_charge1 = 93.3 | |
unit_charge2 = 187.9 | |
unit_charge3 = 280.6 | |
unit_charge4 = 709.5 | |
total_charge = minimum_charge + (unit_charge1 * step1) + (unit_charge2 * (step2 - step1)) + (unit_charge3 * (step3 - step2)) + (unit_charge4 * (kWh - step3)) | |
vat = round(total_charge * 0.1) # 부가세, 원미만 4사 5입 | |
base_fund = int((total_charge * 0.037) / 10) * 10 # 전력산업기반기금, 10원미만 절사 | |
return int((total_charge + vat + base_fund) / 10) * 10 # 10원미만 절사 | |
if __name__ == "__main__": | |
before_calculate_charge = functools.partial(calculate_charge, step1=200, step2=400, step3=1000) | |
after_calculate_charge = functools.partial(calculate_charge, step1=300, step2=500, step3=1000) | |
charge_data = [] | |
for kWh in range(50, 1201, 50): | |
charge_data.append((kWh, before_calculate_charge(kWh), after_calculate_charge(kWh))) | |
df1 = pd.DataFrame(charge_data, columns=['kWh', 'before_charge', 'after_charge']) | |
print(df1.to_string(index=False)) | |
plt.figure(figsize=(18, 6)) | |
plt1 = df1.plot(x='kWh', y=['before_charge', 'after_charge'], kind='line', xticks=df1['kWh'], | |
yticks=range(0, (max(df1['before_charge'])), 50000)) | |
plt.xticks(fontsize=10, rotation=45) | |
plt.grid() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
참고
http://www.segye.com/newsView/20180807001597
http://cyber.kepco.co.kr/ckepco/front/jsp/CY/J/A/CYJAPP000.jsp