Python Forum
merging dataframe into another on a specific row
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
merging dataframe into another on a specific row
#1
I have two dataframes as follows.

1) DF 1 (result extracted from running SQL query on dataset '20200602')
It is 2 rows x 3 columns (the 1ist row is essentially the header)

0 subject test_score
1 math 90

2) DF2 is an existing dataframe which is currently indexed by date.
It is 3 rows x 0 column

2020/06/01
2020/06/02
2020/06/03

So essentially I want to merge DF1 into DF2 in the specific row 2 because DF1 reflects data from 2020/06/02. The final output should:
subject test_score
2020/06/01
2020/06/02 math 90
2020/06/03

Additional question: what if I have one more row for English test score in DF1 which looks like:
0 subject test_score
1 math 90
2 eng 85

So that the final output should be (1st index =date, 2nd index = subject):

test_score
2020/06/01
2020/06/02 math 90
2020/06/02 eng 85
2020/06/03

Any advice on how I should do so in the coding?
Much appreciated your help.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Remove specific values from dataframe jonah88888 0 1,688 Sep-24-2021, 05:09 AM
Last Post: jonah88888
  Setting the x-axis to a specific column in a dataframe devansing 0 1,993 May-23-2021, 12:11 AM
Last Post: devansing
  How to search for specific string in Pandas dataframe Coding_Jam 1 2,415 Nov-02-2020, 09:35 AM
Last Post: PsyPy
  Referring to a specific element in Pandas Dataframe Helmi 2 3,173 Mar-17-2019, 09:12 PM
Last Post: Helmi
  Write specific rows from pandas dataframe to csv file pradeepkumarbe 3 5,432 Oct-18-2018, 09:33 PM
Last Post: volcano63
  extract specific content in a pandas dataframe with a regex? steve1040 0 13,510 Oct-05-2017, 03:17 AM
Last Post: steve1040

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020