[PYTHON] Acquisition of past electricity usage Shikoku Electric Power 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 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 Shikoku 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.

Shikoku Electric Power Transmission and Distribution Denki Forecast

download

python


for y in range(2016, 2020):
  url = "https://www.yonden.co.jp/nw/denkiyoho/csv/juyo_shikoku_{:04}.csv".format(y)
  print(url)
  !wget $url

Read and visualize

python


from glob import glob
import pandas as pd

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

df_juyo = pd.DataFrame()

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

df_juyo.index = pd.to_datetime(df_juyo["DATE"] + " " + df_juyo["TIME"])
df_juyo.pop("Performance(10,000 kW)").plot(figsize=(15,5))

Unknown.png

did it!

The upper limit of Okinawa Electric Power is 1.4 million kWh, Kyushu Electric Power is 15 million kWh, Shikoku Electric Power is 5 million kWh ... I am looking forward to the next electric power company!

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 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
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