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

Okinawa Electric Power Company Forecast

download

python


for y in range(2016, 2020):
  for m in range(1,13):
    
    #Omitted as there is no data before April 2016
    if y == 2016 and m < 4:
      continue
      
    for d in range(1, 32):
      url = "https://www.okiden.co.jp/denki2/juyo_10_{:04}{:02}{:02}.csv".format(y, m, d)
      !wget $url

Read and visualize

python


from glob import glob
import pandas as pd

#Get a list of downloaded files
files = glob("*.csv")
files.sort()

df_juyo = pd.DataFrame()

for f in files:
  print("\r", f, end="")
  try:
    df = pd.read_csv(f, encoding="Shift_JIS", skiprows=7, nrows=24)
  except:
    df = pd.read_csv(f, encoding="Shift_JIS", skiprows=13, nrows=24)
  df_juyo = pd.concat([df_juyo, df])

#Set date and time as index
df_juyo.index = pd.to_datetime(df_juyo["DATE"] + " " + df_juyo["TIME"])
df_juyo = df_juyo.sort_index()

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

ダウンロード.png

did it!

Supplement

If you try to visualize it, you can see a tendency that is different from usual in the latter half of 2018. I thought it was a data error, so I checked it a little and found the graph below. ダウンロード (1).png

When I investigated the disaster in September 2018, I found the following articles. 2018 Typhoon No. 24 (2018)

It seems that there was a great deal of damage.

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

Recommended Posts

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