Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions content/code/python/abstracting-plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]:
Expand Down
9 changes: 4 additions & 5 deletions content/code/python/add-iteration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 4 additions & 4 deletions content/code/python/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 5 additions & 5 deletions content/code/python/initial-version-with-mean.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 5 additions & 5 deletions content/code/python/initial-version-with-precipitation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 5 additions & 5 deletions content/code/python/initial-version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions content/code/python/small-improvements.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions content/code/python/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions content/code/python/towards-pure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading