Home > Enterprise >  how to reorder columns in pyarrow table
how to reorder columns in pyarrow table

Time:12-08

I have pyarrow table which have column order ['A', 'B', 'C', 'D'] I want to change the order of this pyarrow table to ['B', 'D', 'C', 'A'] can we reorder pyarrows table like pandas dataframe ?

CodePudding user response:

You can use pyarrow.Table.select

import pyarrow as pa

table_a_b  = pa.table({
    "A": [1,2,3],
    "B": [4,5,6]
})

table_b_a = table_a_b.select(['B', 'A'])
B A
4 1
5 2
6 3
  • Related