Joining two Pandas DataFrames with an equal number of rows is slightly harder
than it appears. In R, you just use the cbind
function.
As this StackOverflow question shows, in Pandas it’s easy to end up with something like this:
|
|
This results from the indices not being identical. Frustratingly (to me) the
ignore_index
argument doesn’t give the 3-rowed DataFrame I’d hope it gives.
As the accepted answer on that question shows, the thing to do is reset the indices on the DataFrames before concatenating:
|
|