[PYTHON] Acquisition of past electricity usage Kansai Electric Power


I was holding a seminar on electricity usage forecast, and I heard that it is difficult to obtain it because the format of the past electricity consumption published by each electric power company is different. Therefore, I will summarize the data acquisition method for each electric power company.

By the way, the target power companies are Hokkaido Electric Power, Tohoku Electric Power, Tokyo Electric Power, Hokuriku Electric Power, Chubu Electric Power, Kansai Electric Power, Chugoku Electric Power, Shikoku Electric Power, Kyushu Electric Power, Okinawa Electric Power, and this time I will deal with Kansai Electric Power. ..

Note: Repeating a large number of downloads will put a burden on the server, so please download only once or limit the target period.

Operating environment

It works in the environment called Colaboratory of Google.



It seems that you can download the data from the following website.

Kansai Transmission and Distribution Power Supply and Demand Notice



for y in range(2016, 2020):
  for m in range(1,13):
    url = "https://www.kansai-td.co.jp/yamasou/{:04}{:02}_jisseki.zip".format(y, m)
    !wget $url

from glob import glob

files = glob("*.zip")

for f in files:
  !unzip $f

Read and visualize


from glob import glob
import pandas as pd

files = glob("2*.csv")

df_juyo = pd.DataFrame()

for f in files:
  print("\r", f, end="")
    df = pd.read_csv(f, encoding="Shift_JIS", skiprows=10, nrows=24)
    d = df.DATE + " " + df.TIME
    df = pd.read_csv(f, encoding="Shift_JIS", skiprows=16, nrows=24)
  df_juyo = pd.concat([df_juyo, df])


df_juyo.index = pd.to_datetime(df_juyo["DATE"] + " " + df_juyo["TIME"])
df_juyo = df_juyo.sort_index()

df_juyo["Results on the day(10,000 kW)"].plot(figsize=(15,5))


did it!

Due to the large population of the area, it is inevitably a region that uses a lot of electricity.

Looking at the amount of electricity used, there are many things you notice. That's all for Kimura from the scene.


The person who read the article asked me, "It takes too much time, so what should I do if I want the data quickly?", So I decided to sell the data for a while. If you are interested in the data, please see the URL below.


Recommended Posts

Acquisition of past electricity usage Kansai Electric Power
Acquisition of past electricity usage Shikoku Electric Power Edition
Acquisition of past electricity usage Okinawa Electric Power Edition
Acquisition of past electricity usage China Electricity Edition
Acquisition of past power consumption Kyushu Electric Power Edition