<jupyter_start><jupyter_text>1) Load the energy and temperature data sets into a single pandas data frame that is matched by date.<jupyter_code>import pandas as pd

file_1 = pd.read_csv(
    "./Milestone 1 Dataset/hr_temp_20170201-20200131_subset.csv", parse_dates=["DATE"]
)
file_2 = pd.read_csv(
    "./Milestone 1 Dataset/hr_temp_20200201-20200229_subset.csv", parse_dates=["DATE"]
)
file_3 = pd.read_csv(
    "./Milestone 1 Dataset/hrl_load_metered - 20170201-20200131.csv",
    parse_dates=["datetime_beginning_utc", "datetime_beginning_ept"],
)
concatenated_data = pd.concat(
    [file_1, file_2, file_3.rename(columns={"datetime_beginning_utc": "DATE"})]
)
energy_and_temp_df = concatenated_data.loc[:, ["DATE", "HourlyDryBulbTemperature", "mw"]]
energy_and_temp_df = energy_and_temp_df.rename(columns={"HourlyDryBulbTemperature": "temperature"})<jupyter_output><empty_output><jupyter_text>2) Create variables for the hour of day, the day of week, the month, and the year for each observation.<jupyter_code>energy_and_temp_df["year"] = energy_and_temp_df["DATE"].dt.year
energy_and_temp_df["month"] = energy_and_temp_df["DATE"].dt.month
energy_and_temp_df["hour"] = energy_and_temp_df["DATE"].dt.hour
energy_and_temp_df["weekday"] = energy_and_temp_df["DATE"].dt.weekday<jupyter_output><empty_output><jupyter_text>3) Set DATE as index<jupyter_code>energy_and_temp_df = energy_and_temp_df.set_index("DATE")<jupyter_output><empty_output><jupyter_text>4) Interpolate the temperature<jupyter_code>energy_and_temp_df["temperature"] = energy_and_temp_df["temperature"].interpolate("linear")<jupyter_output><empty_output><jupyter_text>5) Split training data and testing data<jupyter_code>training = energy_and_temp_df[:"2019-12-31"]
test = energy_and_temp_df["2020-01":]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13, 'fraction_numerical': 0.042222222222222223, 'mean_word_length': 9.117977528089888, 'pattern_counts': {'":': 3, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '550192', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 719, 'n_tokens_neox': 668, 'n_words': 100, 'path': 'Section 1/Preparing the energy and temperature data.ipynb', 'repo_name': 'williamjamir/Time-Series-in-Python-Forecasting-Energy-Demand', 'size': '1800'}