<jupyter_start><jupyter_text>Data SetupIn this notebook, we demonstrate how to:- setup time series data for this tutorial- visualize the dataThe data in this example is taken from the GEFCom2014 forecasting competition1. It consists of 3 years of hourly electricity load and temperature values between 2012 and 2014. 1<NAME>, <NAME>, <NAME>, <NAME>, <NAME> and <NAME>, "Probabilistic energy forecasting: Global Energy Forecasting Competition 2014 and beyond", International Journal of Forecasting, vol.32, no.3, pp 896-913, July-September, 2016.<jupyter_code>import os
import pandas as pd
import matplotlib.pyplot as plt
import warnings

warnings.filterwarnings("ignore")

%matplotlib inline<jupyter_output><empty_output><jupyter_text>Download the data. (Note: The following code is designed to run on an Azure Notebook (or Unix-like environment). If you are using this notebook in a different environment, you will need to mofidy the code.)<jupyter_code>data_dir = './data'

# If data not downloaded, do so
if not os.path.exists(os.path.join(data_dir, 'GEFCom2014.zip')):
    os.makedirs(data_dir, exist_ok=True)
    # Download and move the zip file
    !wget https://www.dropbox.com/s/pqenrr2mcvl0hk9/GEFCom2014.zip
    !mv GEFCom2014.zip ./data
else:
    print("Nothing to do")<jupyter_output>Nothing to do<jupyter_text>Extract zip file.<jupyter_code># If not done already, extract zipped data and save as compressed csv
from common.extract_data import extract_data

if not os.path.exists(os.path.join(data_dir, 'energy.csv.gz')):
    extract_data(data_dir)
else:
    print("Nothing to do")<jupyter_output>Nothing to do<jupyter_text>Load the data from csv into a Pandas dataframe<jupyter_code>energy = pd.read_csv(os.path.join(data_dir, 'energy.csv.gz'), parse_dates=['timestamp'])
# load_data(data_dir)[['load']]
energy.head()<jupyter_output><empty_output><jupyter_text>Reindex the dataframe such that the dataframe has a record for every time pointbetween the minimum and maximum timestamp in the time series. This helps to identify missing time periods in the data (there are none in this dataset).<jupyter_code>energy.index = energy['timestamp']
energy = energy.reindex(pd.date_range(min(energy['timestamp']),
                                      max(energy['timestamp']),
                                      freq='H'))
energy = energy.drop('timestamp', axis=1)

# Check for missing
energy.isna().any()<jupyter_output><empty_output><jupyter_text>Finally, save as parquet file.<jupyter_code>energy.to_parquet(os.path.join(data_dir, 'energy.parquet'))<jupyter_output><empty_output><jupyter_text>Plot all available load data (January 2012 to Dec 2014)<jupyter_code>energy.plot(y='load', subplots=True, figsize=(15, 8), fontsize=12)
plt.xlabel('timestamp', fontsize=12)
plt.ylabel('load', fontsize=12)
plt.show()<jupyter_output><empty_output><jupyter_text>Plot first week of July 2014<jupyter_code>energy['2014-07-01':'2014-07-07'].plot(y='load', subplots=True, figsize=(15, 8), fontsize=12)
plt.xlabel('timestamp', fontsize=12)
plt.ylabel('load', fontsize=12)
plt.show()<jupyter_output><empty_output>