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/6394 below:

Indexing Regression in 0.13.0 · Issue #6394 · pandas-dev/pandas · GitHub

In pandas 0.12 the order you indexed a DataFrame didn't matter, which I think is the correct behaviour:

In [6]: df = pd.DataFrame({'A': 5*[np.zeros(3)], 'B':5*[np.ones(3)]})

In [7]: df
Out[7]: 

    A   B
0   [0.0, 0.0, 0.0] [1.0, 1.0, 1.0]
1   [0.0, 0.0, 0.0] [1.0, 1.0, 1.0]
2   [0.0, 0.0, 0.0] [1.0, 1.0, 1.0]
3   [0.0, 0.0, 0.0] [1.0, 1.0, 1.0]
4   [0.0, 0.0, 0.0] [1.0, 1.0, 1.0]

In [8]: df['A'].iloc[2]
Out[8]: array([ 0., 0., 0.])

In [9]: df.iloc[2]['A']
Out[9]: array([ 0., 0., 0.])

In [10]: pd.__version__
Out[10]: '0.12.0'

In [11]: assert type(df.ix[2, 'A']) == type(df['A'].iloc[2]) == type(df.iloc[2]['A'])

In [12]: 

In pandas 0.13 if you index in a different order you can get a different type out which can be problematic for code expecting an array, especially because of the difference between array indexing and label indexing.

In [1]: df = pd.DataFrame({'A': 5*[np.zeros(3)], 'B':5*[np.ones(3)]})

In [2]: df
Out[2]: 

    A   B
0   [0.0, 0.0, 0.0] [1.0, 1.0, 1.0]
1   [0.0, 0.0, 0.0] [1.0, 1.0, 1.0]
2   [0.0, 0.0, 0.0] [1.0, 1.0, 1.0]
3   [0.0, 0.0, 0.0] [1.0, 1.0, 1.0]
4   [0.0, 0.0, 0.0] [1.0, 1.0, 1.0]
5 rows × 2 columns 

In [3]: df['A'].iloc[2]
Out[3]: array([ 0., 0., 0.])

In [4]: df.iloc[2]['A']
Out[4]: 
A 0
A 0
A 0
Name: 2, dtype: float64

In [5]: pd.__version__
Out[5]: '0.13.1'

In [6]: assert type(df.ix[2, 'A']) == type(df['A'].iloc[2]) == type(df.iloc[2]['A'])
Traceback (most recent call last):

  File "<ipython-input-11-946e15564ee1>", line 1, in <module>
    assert type(df.ix[2, 'A']) == type(df['A'].iloc[2]) == type(df.iloc[2]['A'])

AssertionError

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