Safe-DS / Library

A user-friendly library for Data Science in Python.
https://library.safeds.com
MIT License
17 stars 4 forks source link

`Cell.first_not_none` #799

Closed lars-reimann closed 2 months ago

lars-reimann commented 4 months ago

Is your feature request related to a problem?

When transforming a column of a table or computing a new one, it is sometimes beneficial to compute multiple values and pick the first that is not None. For example, we might try to transform a column that contains date strings in various formats into an actual date column.

Desired solution

Add a static method Cell.first_not_none. It should have one parameter cells: list[Cell] and return a new cell containing the first non-None cell value. The implementation should use the _LazyCell.

Use pl.coalesce internally.

Return None if all conversions returned None.

Possible alternatives (optional)

No response

Screenshots (optional)

No response

Additional Context (optional)

No response

LIEeOoNn commented 3 months ago

we tried for 2h to implement it but apparently can't be wrapped by polars and stopped after trying everything we could think :(

lars-reimann commented 3 months ago

Do you have your current code in some branch?

LIEeOoNn commented 2 months ago

Do you have your current code in some branch?

we do at #799

lars-reimann commented 2 months ago

I've pushed an implementation of first_not_none to 799-cellfirst_not_none. It still needs documentation (including example usage) and tests, though.

lars-reimann commented 2 months ago

:tada: This issue has been resolved in version 0.27.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: