pandasdataframevaex

reordering columns in vaex?


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.


Solution

  • 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