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!