A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/9777 below:

Predictable order for columns in assign through sorting · Issue #9777 · pandas-dev/pandas · GitHub

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?


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4