Spaces:
Sleeping
Sleeping
Commit
·
4757927
1
Parent(s):
3bd9fcf
fetch_forecast: convert to Date obj to datetime
Browse files- src/fetch_forecast.py +3 -0
src/fetch_forecast.py
CHANGED
|
@@ -43,6 +43,9 @@ class FetchForecast:
|
|
| 43 |
def transform_data(self, data) -> tuple:
|
| 44 |
past_df = pd.DataFrame(data["past"]).rename(columns={"index": "Date"})
|
| 45 |
fcst_df = pd.DataFrame(data["forecast"]).rename(columns={"index": "Date"})
|
|
|
|
|
|
|
|
|
|
| 46 |
# move Date to the front
|
| 47 |
past_df = past_df[["Date"] + [col for col in past_df.columns if col != "Date"]]
|
| 48 |
fcst_df = fcst_df[["Date"] + [col for col in fcst_df.columns if col != "Date"]]
|
|
|
|
| 43 |
def transform_data(self, data) -> tuple:
|
| 44 |
past_df = pd.DataFrame(data["past"]).rename(columns={"index": "Date"})
|
| 45 |
fcst_df = pd.DataFrame(data["forecast"]).rename(columns={"index": "Date"})
|
| 46 |
+
# Convert to dates
|
| 47 |
+
past_df["Date"] = pd.to_datetime(past_df["Date"], utc=True).dt.tz_convert(None)
|
| 48 |
+
fcst_df["Date"] = pd.to_datetime(fcst_df["Date"], utc=True).dt.tz_convert(None)
|
| 49 |
# move Date to the front
|
| 50 |
past_df = past_df[["Date"] + [col for col in past_df.columns if col != "Date"]]
|
| 51 |
fcst_df = fcst_df[["Date"] + [col for col in fcst_df.columns if col != "Date"]]
|