Skip to content

.replaceStrict error when not passing default_ #400

@gustaferiksson

Description

@gustaferiksson

The .replaceStrict requires passing the default_ to what should be used as default value, even though the docs and the types doesn't mark it as required and states "Defaults to keeping the original value."

const df = pl.DataFrame({
    a: [1, 2, 3],
})

const t1 = df.select(pl.col("a").replaceStrict({ old: { 1: 2 } }))
// error: incomplete mapping specified for `replace_strict`
// Hint: Pass a `default` value to set unmapped values.

const t2 = df.select(pl.col("a").replaceStrict({ old: { 1: 2 }, default_: pl.col("a") }))
// shape: (3, 1)
// ┌─────┐
// │ a   │
// │ --- │
// │ f64 │
// ╞═════╡
// │ 2.0 │
// │ 2.0 │
// │ 3.0 │
// └─────┘

const t3 = df.select(pl.col("a").replaceStrict(1, 2))
//error: incomplete mapping specified for `replace_strict`
// Hint: Pass a `default` value to set unmapped values.

const t4 = df.select(pl.col("a").replaceStrict(1, 2, pl.col("a")))
// shape: (3, 1)
// ┌─────┐
// │ a   │
// │ --- │
// │ f64 │
// ╞═════╡
// │ 2.0 │
// │ 2.0 │
// │ 3.0 │
// └─────┘

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdocumentationImprovements or additions to documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions