• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home » Resolved: How can i concat in polars dataframes that have different columns vertically

Resolved: How can i concat in polars dataframes that have different columns vertically

0
By Isaac Tonny on 18/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

In pandas it happens automatically, just by calling pd.concat([df1, df2, df3]) and the frame that didn’t have the column previously just gets a column filled with NaNs.
In polars i get a ‘shape error’ with the message that the columns differ (11 cols in df1 vs 12 cols in df2).

Answer:

Polars cares about schema correctness by default in operations and prefers throwing an error above silently succeeding as it might indicate a bug in your program.
If you want polars to add the columns, you can by setting the direction of the concatenation to "diagonal".

If you have better answer, please add a comment about this, thank you!

python-polars
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: linq2db throws exception when filtering by nested collection

02/04/2023

Resolved: Table data is coming as empty in React

02/04/2023

Resolved: In a Pinescript v5 Strategy why is my bool not working?

02/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.