Deltares/ddlpy

Better error message when providing multiple locations to `ddlpy.measurements()`

Closed this issue · 0 comments

  • ddlpy version: master
  • Python version: 3.11
  • Operating System: Windows

Description

When passing a locations dataframe with multiple rows, ddlpy.measurements() raises "AttributeError: 'DataFrame' object has no attribute 'name'". Maybe catch this and provide a decent error message.

What I Did

Reproducible example:

import ddlpy

locations = ddlpy.locations()

tstart_dt = "2019-12-24"
tstop_dt = "2020-01-05"

bool_hoedanigheid = locations['Hoedanigheid.Code'].isin(['NAP'])
bool_station = locations.index.isin(['HOEKVHLD'])
bool_grootheid = locations['Grootheid.Code'].isin(['WATHTE'])
locs_sel = locations.loc[bool_station & bool_grootheid & bool_hoedanigheid]

meas = ddlpy.measurements(locs_sel, start_date=tstart_dt, end_date=tstop_dt)