Closed
Description
The order of columns coming out of .assign
is hard to predict
In [1]: import pandas as pd
In [2]: df = pd.DataFrame({'a': [1], 'b': [2]})
In [3]: df
Out[3]:
a b
0 1 2
In [4]: df.assign(d=df.a*10, a=df.b*10, e=df.a*20)
Out[4]:
a b e d
0 20 2 20 10
Would it be reasonable to keep all existing keys in their current location and then add the remaining keys in sorted order at the end?