pydata/pandas — pull request #8457 by behzadnouri (2014-10-03 22:15:31+00:00)
Title: type diversity breaks alignment

closes https://github.com/pydata/pandas/issues/8258, but more generally, on pandas master, assignment with indexer will align _both rows and columns_ if all columns have the same type:

>>> cols, idx = ['jim', 'joe', 'jolie'], ['first', 'last']
>>> vals = np.arange(1, 7).reshape(2, 3, order='F')
>>> df = DataFrame(vals, columns=cols, index=idx)
>>> left, rhs = df.copy(), df.iloc[::-1, -2::-1]
>>> print(left, rhs, sep='\n')
jim joe jolie
first 1 3 5
last 2 4 6
joe jim
last 4 2
first 3 1
>>>
>>> left.loc[:, ['jim', 'joe']] = rhs
>>> left
jim joe jolie
first 1 3 5
last 2 4 6

However, if I change the type of a column even _outside_ the section which gets assigned to, _only columns_ are aligned:

>>> df['jolie'] = df['jolie'].astype('float64')
>>> left, rhs = df.copy(), df.iloc[::-1, -2::-1]
>>> print(left, rhs, sep='\n')
jim joe jolie
first 1 3 5
last 2 4 6
joe jim
last 4 2
first 3 1
>>>
>>> left.loc[:, ['jim', 'joe']] = rhs
>>> left
jim joe jolie
first 2 4 5
last 1 3 6

that said, there are two places in tests where they rely on this behaviour, [here](https://github.com/pydata/pandas/blob/fccd7feabfe0bf15c30d712f3a4a4ff71e76ad4a/pandas/tests/test_frame.py#L1405) and [here](https://github.com/pydata/pandas/blob/fccd7feabfe0bf15c30d712f3a4a4ff71e76ad4a/pandas/tests/test_indexing.py#L1033).