Join Rows When Concatenating on Columns
In this final lesson of the second section, about combining data using
concat(), you’ll learn how you can create an inner join on the rows while you’re concatenating your two DataFrames on the columns.
and you can see what happened is that again, you have the
fruits DataFrame with its two, originally two times four, and the
veggies DataFrame, which is still complete with its three times three.
But because the
veggies DataFrame only has three rows, and the
fruits DataFrame has four, pandas got rid of the final row in the
fruits DataFrame after concatenating the two DataFrames on the columns axis. So again, the concatenation always relates to what you define here in the
axis argument, and that just sticks things together. And then with
join, you can define how to deal with the second column. In the previous example, the second axis were the columns, and here you have the primary axis being the columns, so the secondary axis is gonna be the rows.
In this lesson, you learned how you can perform an inner join on the rows while you’re concatenating your two DataFrames on columns. And to do that, you just had to pass the
"columns" string as an argument to the
axis parameter to define that the primary axis for the concatenation is going to be the columns instead of the default rows.
Then you had to keep passing the string
"inner" to the
join parameter to perform an inner join instead of the default outer. Now that wrap up talking about some of the most important keyword arguments that you can pass to change the behavior of
Become a Member to join the conversation.