# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Temperature Data Extraction

import pandas as pd
import numpy as np
import datetime

history_datapath = "Tamjeed_Data_Daily.csv"
modern_datapath = "Tamjeed_Data_Daily_2020.csv"

# ## historical data extraction

history_df = pd.read_csv(history_datapath)
history_df

modern_df = pd.read_csv(modern_datapath)
modern_df

region_history = history_df.loc[history_df["Location"] == "New York"]

region_history

region_hist_temp = region_history["Temperature"]

region_hist_temp.plot()

# +
weeks_before = 2

original_start = 19971004
start_datetime = datetime.datetime.strptime(str(original_start), "%Y%m%d")
new_start_datetime = start_datetime - datetime.timedelta(days=(7*weeks_before))
startdate = int(new_start_datetime.strftime("%Y%m%d"))
startdate_int64 = np.int64(startdate)
regionstartdate = region_history.loc[region_history["Date"] == startdate_int64]

original_end = 20190928
end_datetime = datetime.datetime.strptime(str(original_end), "%Y%m%d")
new_end_datetime = end_datetime - datetime.timedelta(days=(7*weeks_before))
enddate = int(new_end_datetime.strftime("%Y%m%d"))
enddate_int64 = np.int64(enddate)
regionenddate = region_history.loc[region_history["Date"] == enddate_int64]
# -

regionenddate

region_history_timeline = region_history.iloc[regionstartdate.index[0]:regionenddate.index[0]+1]

region_history_timeline_weekly = region_history_timeline.iloc[::7]
region_history_timeline_weekly

region_history_temperature_data = region_history_timeline_weekly["Temperature"]

region_history_temperature_data.plot()

# ## modern temperature extraction

region_modern = modern_df.loc[modern_df["Location"] == "New York"]
region_modern

# +
weeks_before = 2

modern_original_start = 20200122
modern_start_datetime = datetime.datetime.strptime(str(modern_original_start), "%Y%m%d")
modern_new_start_datetime = modern_start_datetime - datetime.timedelta(days=(7*weeks_before))
modern_startdate = int(modern_new_start_datetime.strftime("%Y%m%d"))
modern_startdate_int64 = np.int64(modern_startdate)
modern_regionstartdate = region_modern.loc[region_modern["Date"] == modern_startdate_int64]
# -

modern_regionstartdate

region_modern_timeline = region_modern.iloc[modern_regionstartdate.index[0]:]

region_modern_timeline_weekly = region_modern_timeline.iloc[::7]

region_modern_timeline_weekly

region_modern_temperature_data = region_modern_timeline_weekly["Temperature"]

region_modern_temperature_data.plot()



StarcoderdataJupyterScriptsDedupFiltered