Skip to content

Commit

Permalink
fix fetcher for single and multiple datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
ocefpaf committed Oct 13, 2023
1 parent 6adfaff commit 7bc600b
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions gliderpy/fetchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,14 @@ def to_pandas(self):
:return: pandas dataframe with datetime UTC as index
"""
if type(self.datasets) is pd.Series:
if self.fetcher.dataset_id:
df = self.fetcher.to_pandas(
index_col="time (UTC)",
parse_dates=True,
)
elif not self.fetcher.dataset_id and self.datasets is not None:
df_all = []
for dataset_id in self.datasets:
for dataset_id in self.datasets["Dataset ID"]:
self.fetcher.dataset_id = dataset_id
df = self.fetcher.to_pandas(
index_col="time (UTC)",
Expand All @@ -71,14 +76,11 @@ def to_pandas(self):
df = standardise_df(df, dataset_url)
df_all.append(df)
return pd.concat(df_all)
else:
raise ValueError(
f"Must provide a {self.fetcher.dataset_id} or `query` terms to download data.",
)

if not self.fetcher.dataset_id:
return None

df = self.fetcher.to_pandas(
index_col="time (UTC)",
parse_dates=True,
)
# Standardize variable names.
dataset_url = self.fetcher.get_download_url().split("?")[0]
df = standardise_df(df, dataset_url)
Expand Down

0 comments on commit 7bc600b

Please sign in to comment.