Spaces:
Sleeping
Sleeping
Update cwa_service.py
Browse files- cwa_service.py +5 -2
cwa_service.py
CHANGED
|
@@ -82,8 +82,10 @@ def _parse_significant_earthquakes(obj: dict) -> pd.DataFrame:
|
|
| 82 |
"URL": q.get("Web"),
|
| 83 |
})
|
| 84 |
df = pd.DataFrame(rows)
|
| 85 |
-
if not df.empty:
|
| 86 |
-
|
|
|
|
|
|
|
| 87 |
return df
|
| 88 |
|
| 89 |
def fetch_significant_earthquakes(days: int = 7, limit: int = 5) -> str:
|
|
@@ -122,3 +124,4 @@ def fetch_significant_earthquakes(days: int = 7, limit: int = 5) -> str:
|
|
| 122 |
|
| 123 |
except Exception as e:
|
| 124 |
return f"❌ 顯著地震查詢失敗:{e}"
|
|
|
|
|
|
| 82 |
"URL": q.get("Web"),
|
| 83 |
})
|
| 84 |
df = pd.DataFrame(rows)
|
| 85 |
+
if not df.empty and "Time" in df.columns:
|
| 86 |
+
time_series = pd.to_datetime(df["Time"], errors="coerce")
|
| 87 |
+
# [修正] 先用 tz_localize('UTC') 賦予 UTC 時區,再用 tz_convert 轉換為台北時區
|
| 88 |
+
df["Time"] = time_series.dt.tz_localize("UTC").dt.tz_convert(TAIPEI_TZ)
|
| 89 |
return df
|
| 90 |
|
| 91 |
def fetch_significant_earthquakes(days: int = 7, limit: int = 5) -> str:
|
|
|
|
| 124 |
|
| 125 |
except Exception as e:
|
| 126 |
return f"❌ 顯著地震查詢失敗:{e}"
|
| 127 |
+
|