Skip to content

Commit 511cce8

Browse files
committed
fix: avoid GeoSeries.progress_apply to support pandas 3
1 parent c63f3e9 commit 511cce8

File tree

1 file changed

+16
-26
lines changed

1 file changed

+16
-26
lines changed

meteora/clients/netatmo.py

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
from meteora.clients.mixins import StationsEndpointMixin, VariablesHardcodedMixin
2020
from meteora.utils import DateTimeType, KwargsType, VariablesType
2121

22-
# to show a progress bar in pandas/geopandas apply
23-
tqdm.pandas()
24-
2522
# API endpoints
2623
BASE_URL = "https://api.netatmo.com"
2724
OAUTH2_TOKEN_ENDPOINT = f"{BASE_URL}/oauth2/token"
@@ -491,6 +488,21 @@ def _station_records_from_window(window):
491488
)
492489
return None
493490

491+
response_jsons = (
492+
self._get_content_from_url(
493+
self._stations_endpoint,
494+
params=dict(
495+
lon_sw=window.bounds[0],
496+
lat_sw=window.bounds[1],
497+
lon_ne=window.bounds[2],
498+
lat_ne=window.bounds[3],
499+
),
500+
)
501+
for window in tqdm(
502+
self.region_window_gser,
503+
total=len(self.region_window_gser),
504+
)
505+
)
494506
_stations_df = pd.concat(
495507
[
496508
pd.DataFrame(
@@ -499,29 +511,7 @@ def _station_records_from_window(window):
499511
for station_record in response_json["body"]
500512
],
501513
)
502-
for response_json in self.region_window_gser.progress_apply(
503-
# for response_json, _ in self.region_window_gser.apply(
504-
# lambda window: self._perform_request(
505-
# STATIONS_ENDPOINT,
506-
# data=dict(
507-
# lon_sw=window.bounds[0],
508-
# lat_sw=window.bounds[1],
509-
# lon_ne=window.bounds[2],
510-
# lat_ne=window.bounds[3],
511-
# ),
512-
# )
513-
# we can use the cache to get the stations (note that the same
514-
# endpoint is used to get the latest observations)
515-
lambda window: self._get_content_from_url(
516-
self._stations_endpoint,
517-
params=dict(
518-
lon_sw=window.bounds[0],
519-
lat_sw=window.bounds[1],
520-
lon_ne=window.bounds[2],
521-
lat_ne=window.bounds[3],
522-
),
523-
)
524-
)
514+
for response_json in response_jsons
525515
],
526516
axis="rows",
527517
ignore_index=True,

0 commit comments

Comments
 (0)