polars icon indicating copy to clipboard operation
polars copied to clipboard

Silent casting to the same categorical space in concat

Open kdcd opened this issue 2 years ago • 0 comments

Very nice library, enjoying using it every day very much.

Without pl.Config.set_global_string_cache() in concat polars silently cast second dataframe categorical namespace to the first. If it's possible it would be nice to have warning like in case of join.

import polars as pl
frames = [
    pl.DataFrame([{"s": "1"}]),
    pl.DataFrame([{"s": "2"}]),
]
pl.concat([
    df.with_column(pl.col("s").cast(pl.Categorical))
    for df in frames
])

shape: (2, 1)
s
cat
"1"
"1"

kdcd avatar Jul 02 '22 10:07 kdcd