h2oai / datatable

A Python package for manipulating 2-dimensional tabular data structures
https://datatable.readthedocs.io
Mozilla Public License 2.0
1.81k stars 155 forks source link

`coalesce` or fillna across the rows #3415

Open samukweku opened 1 year ago

samukweku commented 1 year ago

Example:

DT
   |    col1     col2     col3     col4
   | float64  float64  float64  float64
-- + -------  -------  -------  -------
 0 |      NA       NA        2       NA
 1 |       2        5       NA       10
 2 |       4        1        9       11
 3 |       5        0        1        4
 4 |      NA       NA       NA        8
[5 rows x 4 columns]

DT[:, f[:].coalesce(reverse=True)]
   |    col1     col2     col3     col4
   | float64  float64  float64  float64
-- + -------  -------  -------  -------
 0 |       2        2        2       NA
 1 |       2        5       10       10
 2 |       4        1        9       11
 3 |       5        0        1        4
 4 |       8        8        8        8
[5 rows x 4 columns]

[5 rows x 5 columns]