The following answer was provided by Bart when I asked the difference between merge and join. I thought the answer was good enough and wanted to share it and to also remember this important difference.
The join()
and merge()
methods in pandas are used to combine two DataFrames. They are similar in that they both combine DataFrames based on common columns or indices. However, there are some key differences between the two methods:
join()
only joins on the index. If you want to join on columns, you need to set theon
parameter.merge()
can join on columns or indices. You can specify the columns to join on with theon
parameter, or you can specify the indices to join on with theleft_index
andright_index
parameters.join()
by default performs a left join. This means that all rows from the left DataFrame are included in the result, even if there are no matching rows in the right DataFrame.merge()
by default performs an inner join. This means that onl