narwhals-dev / narwhals

Lightweight and extensible compatibility layer between Polars, pandas, cuDF, Modin, and more!
https://narwhals-dev.github.io/narwhals/
MIT License
218 stars 31 forks source link

[Enh]: support creating column with literal value #309

Closed EdAbati closed 1 week ago

EdAbati commented 1 week ago

We would like to learn about your use case. For example, if this feature is needed to adopt Narwhals in an open source project, could you please enter the link to it below?

I'm currently looking at #204 , I found a place where this could be helpful

Please describe the purpose of the new feature or describe the problem to solve.

Similar to polars.lit, it would be nice to have the capability to add a column with a constant value.

Suggest a solution if possible.

I think we could have a narwhals.lit function with a similar signature as polars.lit.

If you have tried alternatives, please describe them below.

No response

Additional information that may help us understand your needs.

Happy to make a PR!