BUG: fix DataFarame column slice indexer by immerrr · Pull Request #6525 · pandas-dev/pandas (original) (raw)

The code pulled in in #6123 didn't account for slice indexers which return views, not copies in take_ref_locs function. As a result, slice across columns corrupted _ref_locs of the parent block (provided _ref_locs existed). This PR should fix that.

In [1]: df = pd.DataFrame(np.random.rand(5,3))

In [2]: df.dtypes Out[2]: 0 float64 1 float64 2 float64 dtype: object

In [3]: df.iloc[:,2:] Out[3]: 2 0 0.524160 1 0.072608 2 0.289047 3 0.494401 4 0.235275

[5 rows x 1 columns]

In [4]: _3.dtypes Out[4]: 2 float64 dtype: object

In [5]: df.dtypes Out[5]: 0 float64 1 float64 2 None dtype: object

In [6]: pd.version Out[6]: '0.13.1-346-g30d3cba'