diff --git a/content/code/python/abstracting-plot.py b/content/code/python/abstracting-plot.py index c2f7303..79a77a5 100644 --- a/content/code/python/abstracting-plot.py +++ b/content/code/python/abstracting-plot.py @@ -40,11 +40,11 @@ def plot(column, label, location, color, compute_mean): # read data data = pd.read_csv("weather_data.csv") -# combine 'date' and 'time' into a single datetime column -data["datetime"] = pd.to_datetime(data["date"] + " " + data["time"]) +# combine 'date' and 'time' into a single column 'recorded_at' as type datetime +data["recorded_at"] = pd.to_datetime(data["date"] + " " + data["time"]) -# set datetime as index for convenience -data = data.set_index("datetime") +# set 'recorded_at' as index for convenience +data = data.set_index("recorded_at") for month in ["2024-01", "2024-02", "2024-03"]: diff --git a/content/code/python/add-iteration.py b/content/code/python/add-iteration.py index ea262f8..162fb68 100644 --- a/content/code/python/add-iteration.py +++ b/content/code/python/add-iteration.py @@ -5,12 +5,11 @@ # read data data = pd.read_csv("weather_data.csv") -# combine 'date' and 'time' into a single datetime column -data["datetime"] = pd.to_datetime(data["date"] + " " + data["time"]) - -# set datetime as index for convenience -data = data.set_index("datetime") +# combine 'date' and 'time' into a single column 'recorded_at' as type datetime +data["recorded_at"] = pd.to_datetime(data["date"] + " " + data["time"]) +# set 'recorded_at' as index for convenience +data = data.set_index("recorded_at") for month in ["2024-01", "2024-02", "2024-03"]: data_month = data.loc[month] diff --git a/content/code/python/cli.py b/content/code/python/cli.py index 2278414..dbc9e6a 100644 --- a/content/code/python/cli.py +++ b/content/code/python/cli.py @@ -10,11 +10,11 @@ def read_data(file_name): data = pd.read_csv(file_name) - # combine 'date' and 'time' into a single datetime column - data["datetime"] = pd.to_datetime(data["date"] + " " + data["time"]) + # combine 'date' and 'time' into a single column 'recorded_at' as type datetime + data["recorded_at"] = pd.to_datetime(data["date"] + " " + data["time"]) - # set datetime as index for convenience - data = data.set_index("datetime") + # set 'recorded_at' as index for convenience + data = data.set_index("recorded_at") return data diff --git a/content/code/python/initial-version-with-mean.py b/content/code/python/initial-version-with-mean.py index 6fe191e..558db6c 100644 --- a/content/code/python/initial-version-with-mean.py +++ b/content/code/python/initial-version-with-mean.py @@ -5,13 +5,13 @@ # read data data = pd.read_csv("weather_data.csv") -# combine 'date' and 'time' into a single datetime column -data["datetime"] = pd.to_datetime(data["date"] + " " + data["time"]) +# combine 'date' and 'time' into a single column 'recorded_at' as type datetime +data["recorded_at"] = pd.to_datetime(data["date"] + " " + data["time"]) -# set datetime as index for convenience -data = data.set_index("datetime") +# set 'recorded_at' as index for convenience +data = data.set_index("recorded_at") -# keep only january data +# keep only january data using datetime period indexing january = data.loc["2024-01"] fig, ax = plt.subplots() diff --git a/content/code/python/initial-version-with-precipitation.py b/content/code/python/initial-version-with-precipitation.py index a50f079..97fad53 100644 --- a/content/code/python/initial-version-with-precipitation.py +++ b/content/code/python/initial-version-with-precipitation.py @@ -5,13 +5,13 @@ # read data data = pd.read_csv("weather_data.csv") -# combine 'date' and 'time' into a single datetime column -data["datetime"] = pd.to_datetime(data["date"] + " " + data["time"]) +# combine 'date' and 'time' into a single column 'recorded_at' as type datetime +data["recorded_at"] = pd.to_datetime(data["date"] + " " + data["time"]) -# set datetime as index for convenience -data = data.set_index("datetime") +# set 'recorded_at' as index for convenience +data = data.set_index("recorded_at") -# keep only january data +# keep only january data using datetime period indexing january = data.loc["2024-01"] fig, ax = plt.subplots() diff --git a/content/code/python/initial-version.py b/content/code/python/initial-version.py index b22db27..9f0f7c0 100644 --- a/content/code/python/initial-version.py +++ b/content/code/python/initial-version.py @@ -5,13 +5,13 @@ # read data data = pd.read_csv("weather_data.csv") -# combine 'date' and 'time' into a single datetime column -data["datetime"] = pd.to_datetime(data["date"] + " " + data["time"]) +# combine 'date' and 'time' into a single column 'recorded_at' as type datetime +data["recorded_at"] = pd.to_datetime(data["date"] + " " + data["time"]) -# set datetime as index for convenience -data = data.set_index("datetime") +# set 'recorded_at' as index for convenience +data = data.set_index("recorded_at") -# keep only january data +# keep only january data using datetime period indexing january = data.loc["2024-01"] fig, ax = plt.subplots() diff --git a/content/code/python/small-improvements.py b/content/code/python/small-improvements.py index 322878b..d02883a 100644 --- a/content/code/python/small-improvements.py +++ b/content/code/python/small-improvements.py @@ -5,11 +5,11 @@ def read_data(file_name): data = pd.read_csv(file_name) - # combine 'date' and 'time' into a single datetime column - data["datetime"] = pd.to_datetime(data["date"] + " " + data["time"]) + # combine 'date' and 'time' into a single column 'recorded_at' as type datetime + data["recorded_at"] = pd.to_datetime(data["date"] + " " + data["time"]) - # set datetime as index for convenience - data = data.set_index("datetime") + # set 'recorded_at' as index for convenience + data = data.set_index("recorded_at") return data diff --git a/content/code/python/testing.py b/content/code/python/testing.py index 56d406d..c631434 100644 --- a/content/code/python/testing.py +++ b/content/code/python/testing.py @@ -6,11 +6,11 @@ def read_data(file_name): data = pd.read_csv(file_name) - # combine 'date' and 'time' into a single datetime column - data["datetime"] = pd.to_datetime(data["date"] + " " + data["time"]) + # combine 'date' and 'time' into a single column 'recorded_at' as type datetime + data["recorded_at"] = pd.to_datetime(data["date"] + " " + data["time"]) - # set datetime as index for convenience - data = data.set_index("datetime") + # set 'recorded_at' as index for convenience + data = data.set_index("recorded_at") return data diff --git a/content/code/python/towards-pure.py b/content/code/python/towards-pure.py index 1cb0ddc..1d7933f 100644 --- a/content/code/python/towards-pure.py +++ b/content/code/python/towards-pure.py @@ -5,11 +5,11 @@ def read_data(file_name): data = pd.read_csv(file_name) - # combine 'date' and 'time' into a single datetime column - data["datetime"] = pd.to_datetime(data["date"] + " " + data["time"]) + # combine 'date' and 'time' into a single column 'recorded_at' as type datetime + data["recorded_at"] = pd.to_datetime(data["date"] + " " + data["time"]) - # set datetime as index for convenience - data = data.set_index("datetime") + # set 'recorded_at' as index for convenience + data = data.set_index("recorded_at") return data