Код: Выделить всё
import polars as pl
df1 = pl.from_repr("""
┌─────┬──────┐
│ a ┆ b │
│ --- ┆ --- │
│ i64 ┆ i64 │
╞═════╪══════╡
│ 1 ┆ 4 │
│ 2 ┆ null │
│ 3 ┆ null │
└─────┴──────┘
""")
df2 = pl.from_repr("""
┌──────┬─────┐
│ b ┆ c │
│ --- ┆ --- │
│ i64 ┆ i64 │
╞══════╪═════╡
│ null ┆ 6 │
│ 5 ┆ 7 │
│ null ┆ 8 │
└──────┴─────┘
""")
Код: Выделить всё
┌─────┬──────┬─────┐
│ a ┆ b ┆ c │
│ --- ┆ --- ┆ --- │
│ i64 ┆ i64 ┆ i64 │
╞═════╪══════╪═════╡
│ 1 ┆ 4 ┆ 6 │
│ 2 ┆ 5 ┆ 7 │
│ 3 ┆ null ┆ 8 │
└─────┴──────┴─────┘
Код: Выделить всё
df1.update(df2).hstack(df2.select([c for c in df2.columns if c not in df1.columns]))
Подробнее здесь: https://stackoverflow.com/questions/772 ... -same-time