BUG: surprising non-error when assigning a multi-column DataFrame to a single column · Issue #38604 · pandas-dev/pandas (original) (raw)


Assigning a multi-column DataFrame to a single column does not raise an error and simply assigns the first column of the DataFrame to the column. Below is an example:

df1 = pd.DataFrame({'a': [0, 1, 2, 3], 'b': [4, 5, 6, 7]}) df2 = pd.DataFrame({'c': [8, 9, 10, 11], 'd': [12, 13, 14, 15]}) df1['b'] = df2

This seems like one of the instances where not raising an error might ease some short-term pain but could mask underlying issues with a user's code. This behavior seems to have been around for a while. It occurs in master and as far back as 1.0.3.