Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to reorder columns in pyarrow table

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 ?

like image 495
amber_coder Avatar asked Sep 07 '25 21:09

amber_coder


1 Answers

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
like image 163
0x26res Avatar answered Sep 10 '25 06:09

0x26res