The following used to work:
pl.concat_arr(pl.col("X[m]", "Y[m]", "Z[m]")).alias("Antenna_position[m]"),
but now (polars 1.31.0) I get an error:
Traceback (most recent call last):
File "/usr/pueoBuilder/components/pueoAnalysisTools/SharedUtils/antenna_attributes.py", line 307, in <module>
generate_dataframe_from_pueodata_qrh()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/pueoBuilder/components/pueoAnalysisTools/SharedUtils/antenna_attributes.py", line 186, in generate_dataframe_from_pueodata_qrh
).collect()
~~~~~~~^^
File "/usr/local/lib64/python3.13/site-packages/polars/_utils/deprecation.py", line 97, in wrapper
return function(*args, **kwargs)
File "/usr/local/lib64/python3.13/site-packages/polars/lazyframe/opt_flags.py", line 330, in wrapper
return function(*args, **kwargs)
File "/usr/local/lib64/python3.13/site-packages/polars/lazyframe/frame.py", line 2332, in collect
return wrap_df(ldf.collect(engine, callback))
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
polars.exceptions.DuplicateError: the name 'Antenna_position[m]' is duplicate
It's possible that multiple expressions are returning the same default column name. If this is the case, try renaming the columns with `.alias("new_name")` to avoid duplicate column names.
The solution is simple: change the line to
pl.concat_arr("X[m]", "Y[m]", "Z[m]").alias("Antenna_position[m]"),
or use List
instead of Array
pl.concat_list(pl.col("X[m]", "Y[m]", "Z[m]")).alias("Antenna_position[m]"),
Polars's documentation recommends using Array
over List
for performance, so I guess the first workaround would probably be more ideal.
It looks like Polars Array's concat_arr
is still unstable, but does anyone know why this feature got removed?
That is a known bug and has been fixed on the main branch, but there hasn't been any releases since then. See https://github.com/pola-rs/polars/issues/23267
You can use 1.30 until polars releases 1.32, or use pl.concat_arr(pl.col('x'), pl.col('y'))
as a workaround if you want to use 1.31