Created
August 21, 2024 16:02
-
-
Save ianmcook/a04a17e2cc5ce6459049585b610bf0d5 to your computer and use it in GitHub Desktop.
Union two Ibis tables with columns in different orders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ibis | |
import random | |
con = ibis.connect("duckdb://penguins.ddb") | |
con.create_table( | |
"penguins", ibis.examples.penguins.fetch().to_pyarrow(), overwrite = True | |
) | |
ibis.options.interactive = True | |
penguins = con.table("penguins") | |
penguins.count() # returns 344 | |
penguins | |
columns = penguins.columns | |
random.shuffle(columns) | |
more_penguins = penguins[columns] | |
more_penguins | |
double_the_penguins = ibis.union(penguins, more_penguins) | |
double_the_penguins.count() # returns 688 | |
double_the_penguins |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment