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

Series nil vs NaN #1010

Open
kylewhite21 opened this issue Oct 23, 2024 · 2 comments
Open

Series nil vs NaN #1010

kylewhite21 opened this issue Oct 23, 2024 · 2 comments

Comments

@kylewhite21
Copy link

Are there any recommendations on how to deal with Series NaN values? I'd like to use fill_missing/2 or coalesce, but they seem to ignore NaN. Even if it were possible to explicitly convert or cast a NaN to nil first.

alias Explorer.Series, as: S

s1 = S.from_list([2, 0])
s2 = S.from_list([1, 0])
S.divide(s1, s2) |> S.fill_missing(0.0)

#Explorer.Series<
  Polars[2]
  f64 [2.0, NaN]
>

s = S.from_list([1, nil])
S.fill_missing(s, 0)

#Explorer.Series<
  Polars[2]
  s64 [1, 0]
>
@josevalim
Copy link
Member

You can probably do this: S.select(S.is_nan(s), 0, s) although we may consider adding a fill_nan for convenience.

@kylewhite21
Copy link
Author

Ok, thanks for the quick reply as usual. I'm good with this. You're welcome to close it unless you want to use it to track work for fill_nan.

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

No branches or pull requests

2 participants