dark
dark

Reputation: 256

pandas dataframe join-like operation

I have a pd.Dataframe that contains the following:

student_id,course_id,mark

another dataframe contains:

date,student_id,course_id

I want to perform a "join" on both of the data in a such way that my resulting dataframe would contain:

date,student_id,course_id,mark

but I also do want it to be joined based on the double key (student_id,course_id) which is going to be unique in my dataframe.

How can I perform this?

Thanks a lot in advance.

Upvotes: 2

Views: 172

Answers (1)

dark
dark

Reputation: 256

sorry my bad, the answer was in the doc

result = pd.merge(left, right, how='left', on=['key1', 'key2'])

Upvotes: 1

Related Questions