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

Function to fill NaN with a value (e.g. 0.0) #788

Open
johnkouman opened this issue Feb 4, 2025 · 0 comments · May be fixed by #789
Open

Function to fill NaN with a value (e.g. 0.0) #788

johnkouman opened this issue Feb 4, 2025 · 0 comments · May be fixed by #789

Comments

@johnkouman
Copy link

johnkouman commented Feb 4, 2025

Is your feature request related to a problem? Please describe.
I had a dataset with some items inside and some items had NaN. In pandas and xarray there is the function [.fillna(value)] which fills the NaN with the value. I searched in mikeio lib and didn't find it or a similar.

Describe the solution you'd like
To solve the issue and continue, I copied the dataset, I converted to xarray, applied the .fillnan and replaced the 'new' values to dataset.

dfsu_concat = dfsu_concat.copy()
    dfsu_concat_xray = dfsu_concat.to_xarray().fillna(0)
    variable_values = {
        var_name: dfsu_concat_xray[var_name].values
        for var_name in dfsu_concat_xray.data_vars
    }

dfsu_concat = mikeio.Dataset(
      data=variable_values.values(),
      time=dfsu_concat.time,
      items=dfsu_concat.items,
      geometry=dfsu_concat.geometry,
  )
@ecomodeller ecomodeller linked a pull request Feb 6, 2025 that will close this issue
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