Skip to content

Commit

Permalink
add empty df warning message helper function. call it where empty dat…
Browse files Browse the repository at this point in the history
…aframes can be returned by IVDataService.get
  • Loading branch information
aaraney committed Sep 3, 2021
1 parent 67d7687 commit cd559b3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions python/nwis_client/src/hydrotools/nwis_client/iv.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,19 +247,23 @@ def list_to_df_helper(item: dict):

return df

def empty_df_warning_helper():
warning_message = "No data was returned by the request."
warnings.warn(warning_message)

list_of_frames = list(map(list_to_df_helper, raw_data))

# Empty list. No data was returned in the request
if not list_of_frames:
warning_message = "No data was returned by the request."
warnings.warn(warning_message)
empty_df_warning_helper()
return _create_empty_canonical_df()

# Concatenate list in single pd.DataFrame
dfs = pd.concat(list_of_frames, ignore_index=True)

# skip data processing steps if no data was retrieved and return empty canonical df
if dfs.empty:
empty_df_warning_helper()
return _create_empty_canonical_df()

# Convert values to numbers
Expand Down

0 comments on commit cd559b3

Please sign in to comment.