Skip to content

Commit

Permalink
return empty dataframe instead of none
Browse files Browse the repository at this point in the history
  • Loading branch information
veenstrajelmer committed Mar 12, 2024
1 parent 74cc608 commit 8620545
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ddlpy/ddlpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,9 @@ def measurements(location, start_date, end_date, clean_df=True):
continue

if len(measurements) == 0:
# early return in case of no data
# return empty dataframe in case of no data
logger.debug("no data found for this station and time extent")
return
return pd.DataFrame()

measurements = pd.concat(measurements)

Expand Down
8 changes: 8 additions & 0 deletions tests/test_ddlpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ def test_measurements_amount(location):
assert data_amount_jaar["Groeperingsperiode"].str.len().iloc[0] == 4


def test_measurements_empty(location):
"""measurements for a location """
start_date = dt.datetime(2153, 1, 1)
end_date = dt.datetime(2153, 1, 2)
measurements = ddlpy.measurements(location, start_date=start_date, end_date=end_date)
assert measurements.empty


def test_measurements(location):
"""measurements for a location """
start_date = dt.datetime(1953, 1, 1)
Expand Down

0 comments on commit 8620545

Please sign in to comment.