Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider catching empty measurement dataframes #115

Closed
veenstrajelmer opened this issue Aug 23, 2024 · 1 comment · Fixed by #117
Closed

Consider catching empty measurement dataframes #115

veenstrajelmer opened this issue Aug 23, 2024 · 1 comment · Fixed by #117

Comments

@veenstrajelmer
Copy link
Collaborator

veenstrajelmer commented Aug 23, 2024

When calling kw.calc_havengetallen() with an empty dataframe like so:

import pandas as pd
import kenmerkendewaarden as kw
time_index = pd.DatetimeIndex([], dtype='datetime64[ns, Etc/GMT-1]', name='time', freq=None)
df_ext = pd.DataFrame({"HWLWcode":[]},index=time_index)
df_ext.attrs["station"] = "dummy"
kw.calc_havengetallen(df_ext=df_ext)

We get a confusing error from raise_extremes_with_aggers(): "ValueError: df_ext should only contain extremes (HWLWcode 1/2), but it also contains aggers (HWLWcode 3/4/5). You can convert with hatyan.calc_HWLW12345to12()". When fixing this, we get "ValueError: cannot convert float NaN to integer" from kw.havengetallen.calc_HWLW_moonculm_combi(). Consider catching empty dataframes (both wl and ext) troughout kenmerkendewaarden code.

@veenstrajelmer veenstrajelmer mentioned this issue Aug 23, 2024
48 tasks
@veenstrajelmer
Copy link
Collaborator Author

Prevented this issue in raise_extremes_with_aggers() by improving it, but since empty dataframes raise different errors throughout the code, one should just not work with them. Does not make sense to add checks to each function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant