DataFrame assignment bug - columns getting jumbled (0.13.1)
I am trying to write Python Pandas code to merge the data in two DataFrames, with the new DataFrame's data replacing the old DataFrame's data if the index and columns are identical. There seems to be a bug in Pandas that sometimes causes the column names to be mixed up.

Here is an example. First, create the two DataFrames:

```
In [1]: df1 = DataFrame([[1, 2, 3, 4]]*3, columns=["A1", "B2", "C3", "D4"], index=[0, 1, 2])

In [2]: df2 = DataFrame([[30, 10, 40, 20]]*3, columns=["C3", "A1", "D4", "B2"], index=[1, 2, 3])

In [3]: df1
Out[3]:
   A1  B2  C3  D4
0   1   2   3   4
1   1   2   3   4
2   1   2   3   4

[3 rows x 4 columns]

In [4]: df2
Out[4]:
   C3  A1  D4  B2
1  30  10  40  20
2  30  10  40  20
3  30  10  40  20

[3 rows x 4 columns]
```

Notice df1 and df2 have the same columns but the index is offset by 1. The data in df2 is 10 times df1.

Now try merging the data:

```
In [5]: merge_df = DataFrame(index=df1.index.union(df2.index), columns=df1.columns.union(df2.columns))

In [6]: merge_df.loc[df1.index, df1.columns] = df1

In [7]: merge_df.loc[df2.index, df2.columns] = df2

In [8]: merge_df
Out[8]:
   A1  B2  C3  D4
0   1   2   3   4
1  10  20  30  40
2  10  20  30  40
3  10  20  30  40

[4 rows x 4 columns]
```

That worked correctly.

Now change df2 so that it has the same index values and repeat the same merge procedure.

```
In [9]: df2 = DataFrame([[30, 10, 40, 20]]*3, columns=["C3", "A1", "D4", "B2"], index=[0, 1, 2])

In [10]: df2
Out[10]:
   C3  A1  D4  B2
0  30  10  40  20
1  30  10  40  20
2  30  10  40  20

[3 rows x 4 columns]

In [11]: merge_df = DataFrame(index=df1.index.union(df2.index), columns=df1.columns.union(df2.columns))

In [12]: merge_df.loc[df1.index, df1.columns] = df1

In [13]: merge_df.loc[df2.index, df2.columns] = df2

In [14]: merge_df
Out[14]:
   A1  B2  C3  D4
0  30  10  40  20
1  30  10  40  20
2  30  10  40  20

[3 rows x 4 columns]
```

The column names are in the same order as df1 but the data is as it is in df2! How did that happen?

This is a bug I discovered on my work (Windows) computer. I am using Anaconda Python (Python 2.7.6 |Anaconda 1.9.2 (64-bit)| (default, Nov 11 2013, 10:49:15) [MSC v.1500 64 bit (AMD64)]) with numpy version 1.8.0 and pandas version 0.13.1.

Interestingly I cannot reproduce the problem on my home computer. This (Ubuntu) computer has the same version of Python and Pandas but numpy 1.8.2. I installed 1.8.2 on my work computer but that did not fix the problem.

I tried posting this on stackoverflow but nobody was able to help me.

http://stackoverflow.com/questions/27712500/pandas-dataframe-assignment-issue-possible-bug

This is an important bug for my team as it caused critical analytical errors. I wrote a workaround for the place where I found it but we fear we are making the same mistake elsewhere. We would like a real fix. I imagine we could all upgrade to the 0.15.1 of Pandas and that would probably make it go away, but our team can't handle the consequences of jumping two versions right now. Does anyone know where this bug comes from? Am I confused and am doing something wrong? What do I need to do to fix this?

Thank you.
