markfairbanks / tidypolars

Tidy interface to polars
http://tidypolars.readthedocs.io
MIT License
321 stars 10 forks source link

Use `how = "diagonal"` in `.bind_rows()` #144

Closed markfairbanks closed 2 years ago

markfairbanks commented 2 years ago

This matches dplyr default

import polars as pl
df1 = pl.DataFrame({'x': ['a', 'a'], 'y': range(2), 'z': range(2)})
df2 = pl.DataFrame({'y': range(4, 6), 'x': ['b', 'b']})
pl.concat([df1, df2], how = "diagonal")
┌─────┬─────┬──────┐
│ x   ┆ y   ┆ z    │
│ --- ┆ --- ┆ ---  │
│ str ┆ i64 ┆ i64  │
╞═════╪═════╪══════╡
│ a   ┆ 0   ┆ 0    │
├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌┤
│ a   ┆ 1   ┆ 1    │
├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌┤
│ b   ┆ 4   ┆ null │
├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌┤
│ b   ┆ 5   ┆ null │
└─────┴─────┴──────┘