Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should pl.concat() accept Expr input? #19813

Open
2 tasks done
etiennebacher opened this issue Nov 15, 2024 · 5 comments · May be fixed by #20031
Open
2 tasks done

Should pl.concat() accept Expr input? #19813

etiennebacher opened this issue Nov 15, 2024 · 5 comments · May be fixed by #20031
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars

Comments

@etiennebacher
Copy link
Contributor

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of Polars.

Reproducible example

import polars as pl

df = pl.DataFrame({"x": [1]})

pl.concat([df, df], how = "foo")
# ValueError: DataFrame `how` must be one of {'vertical', 'vertical_relaxed', 'diagonal', 'diagonal_relaxed', 'horizontal', 'align'}, got 'foo'

df.select(pl.concat([pl.col("x"), pl.col("x")], how = "foo"))
# shape: (2, 1)
# ┌─────┐
# │ x   │
# │ --- │
# │ i64 │
# ╞═════╡
# │ 1   │
# │ 1   │
# └─────┘

Log output

No response

Issue description

Might simply be a documentation issue, but it's unclear to me whether Expr should be accepted input inpl.concat(). The docs of items say:

DataFrames, LazyFrames, or Series to concatenate.

They also don't mention the fact that when the inputs are Expr, how can take any value, even "foo" as in the example above.

Expected behavior

Either an update in the docs saying that Expr are accepted and that in this case how doesn't matter, or forbidding Expr as input.

Installed versions

--------Version info---------
Polars:              1.13.1
Index type:          UInt32
Platform:            Linux-6.8.0-48-generic-x86_64-with-glibc2.39
Python:              3.12.3 (main, Sep 11 2024, 14:17:37) [GCC 13.2.0]
LTS CPU:             False

----Optional dependencies----
adbc_driver_manager  <not installed>
altair               <not installed>
cloudpickle          <not installed>
connectorx           <not installed>
deltalake            <not installed>
fastexcel            <not installed>
fsspec               <not installed>
gevent               <not installed>
great_tables         <not installed>
matplotlib           <not installed>
nest_asyncio         <not installed>
numpy                2.1.2
openpyxl             <not installed>
pandas               <not installed>
pyarrow              <not installed>
pydantic             <not installed>
pyiceberg            <not installed>
sqlalchemy           <not installed>
torch                <not installed>
xlsx2csv             <not installed>
xlsxwriter           <not installed>
@etiennebacher etiennebacher added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Nov 15, 2024
@ritchie46
Copy link
Member

No, it's not meant for expressions.

I also don't think it should document what it does not support. It should document what it does. The docs seem pretty clear in that regard.

@eitsupi
Copy link
Contributor

eitsupi commented Nov 15, 2024

No, it's not meant for expressions.

Does it seem that the process is actually taking place at this location?

elif isinstance(first, pl.Expr):
return wrap_expr(plr.concat_expr([e._pyexpr for e in elems], rechunk))

@eitsupi
Copy link
Contributor

eitsupi commented Nov 16, 2024

That was added in #3541

@ritchie46
Copy link
Member

Ah, my bad. Then it should. :)

@ritchie46
Copy link
Member

Can the docstring be updated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars
Projects
None yet
3 participants