[PYTHON] Acquisition of past electricity usage China Electricity Edition

Introduction

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 electric 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 Chugoku 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.

Colaboratory

Website

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

Chugoku Electric Power Network Denki Forecast

download

python


for y in range(2016, 2020):
  url = "https://www.energia.co.jp/nw/jukyuu/sys/juyo-{:04}.csv".format(y)
  print(url)
  !wget $url

As of September 2020, it seems that the data from April 2018 has been released when it is executed.

Read and visualize

python


from glob import glob
import pandas as pd

files = glob("j*.csv")
files.sort()
print(files)

df_juyo = pd.DataFrame()

for f in files:
  df = pd.read_csv(f, skiprows=2, encoding="Shift_JIS")
  df_juyo = pd.concat([df_juyo, df])

print(df_juyo.shape)
print(df_juyo.columns)

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

df_juyo["Performance(10,000 kW)"].plot(figsize=(15,5))

Unknown.png

did it!

Since the past electricity usage results may not be disclosed, continuous data collection is necessary.

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

Supplement

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.

https://ticket.tsuku2.jp/eventsDetail.php?ecd=16260900020422

Recommended Posts

Acquisition of past electricity usage China Electricity Edition
Acquisition of past electricity usage Shikoku Electric Power Edition
Acquisition of past electricity usage Okinawa Electric Power Edition
Acquisition of past electricity usage Kansai Electric Power
Acquisition of past power consumption Kyushu Electric Power Edition
Summary of pyenv usage
Basic usage of flask-classy
Basic usage of Jinja2
Usage of Python locals ()
Basic usage of SQLAlchemy