I have two data frames with data, now I want to merge the fields of the second data frame to first. If I call the index of the first data frame needs to get all the subject and topic names like below. Can anyone help me with this?
import pandas as pd
sub_data = {'Subjectid':['10','11'],'Author':['Author1','Author2'],'SubjectName':['Maths', 'English']}
df1 = pd.DataFrame(sub_data)
print(df1)
topic_data = {'Topicid':['100','101','102'],'Subjectid':['10','10','11'],'TopicName':['Geometry','Trignometry', 'Tenses']}
df2 = pd.DataFrame(topic_data)
print(df2)
subtopic_data = {'Subtopicid':['1000','1001','1002'],'Topicid':['100','101','102'],'Subjectid':['10','10','11'],'SubtopicTopicName':['Lines','Angles', 'PresentTenses']}
df3 = pd.DataFrame(subtopic_data)
print(df3)
Desired Output:
Author SubjectName topicid TopicName Subopicid SubtopicName
10 Author1 Maths 100 Geometry 1000 Lines
10 Author1 Maths 100 Trignometry 1001 Angles