Task 3: Deal with missing hours - Wrong Solution
timestamp_start = "2020-01-01 00:00"
timestamp_end = "2020-12-31 23:00"
expected_timestamps = pandas.date_range(start=timestamp_start, end=timestamp_end, freq="H")
for timestamp in expected_timestamps:
if not (weather_data[LABEL_DATETIME]] == timestamp).any():
weather_data.append(pandas.Series(name=timestamp))`
The input weather_data[LABEL_DATETIME]]
for the if not condition does not work.
First of all the square bracket is closed twice.
If we have already used LABEL_DATETIME
as an index value, we can no longer use it as a column name.
Replacing weather_data[LABEL_DATETIME]]
with weather_data.index
does the trick.
Edit: Formatting
Edited by Erxleben, Fredo