Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions examples/test_brazil_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
logging.basicConfig(level=logging.INFO)

gauge_ids = [
"15400000",
"14515000",
]
variable = constants.STAGE_DAILY_MEAN
start_date = "2023-01-01"
end_date = "2024-12-31"
variable = constants.DISCHARGE_DAILY_MEAN
start_date = "1980-01-01"
end_date = None

plt.figure(figsize=(12, 6))

Expand Down
7 changes: 6 additions & 1 deletion rivretrieve/brazil.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ def _parse_data(self, gauge_id: str, raw_data: List[Dict[str, Any]], variable: s
continue

month_df = pd.DataFrame(list(day_values.items()), columns=[constants.TIME_INDEX, variable])
all_dfs.append(month_df)
if not month_df.empty:
all_dfs.append(month_df)

if not all_dfs:
return pd.DataFrame(columns=[constants.TIME_INDEX, variable])
Expand Down Expand Up @@ -361,6 +362,10 @@ def get_data(
try:
raw_data = self._download_data(gauge_id, variable, start_date, end_date)
df = self._parse_data(gauge_id, raw_data, variable)

if df.empty:
return df

start_date_dt = pd.to_datetime(start_date)
end_date_dt = pd.to_datetime(end_date)
df = df[(df.index >= start_date_dt) & (df.index <= end_date_dt)]
Expand Down