my question is how do I reorder columns in vaex. for example, I want the 5th column at number 1 and the first column at number 5, etc. I know we can use the reindex method in pandas, is there a way to mimic that in vaex. thanks for your help.
Asked
Active
Viewed 506 times
1
-
I guess you got your answer here: https://github.com/vaexio/vaex/discussions/1913 – Joco Feb 16 '22 at 09:27
-
Should be the same in both vaex and pandas. If a column has columns called, say "a", "b", "c", you can reorder the like this `df = df[['c', 'b', 'a']]`. – Joco Feb 17 '22 at 00:46
1 Answers
1
I think you can do this by selecting the columns in the order that you want.
import vaex
df = vaex.from_arrays(a=[1,2,3], b=[4,5,6])
display(df) # first a, then b
df = df[["b","a"]]
display(df) # first b, then a

Ben Epstein
- 81
- 3