merging dataframe into another on a specific row - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: merging dataframe into another on a specific row (/thread-29862.html) |
merging dataframe into another on a specific row - danlin123 - Sep-23-2020 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. |