kilojoules
kilojoules

Reputation: 10093

Pandas merge two dataframes by time column

I have been struggling to merge data frames. I need to have the rows arranged by the time, with both sets of data's columns merged into a new data frame. I'm sorry if this is clearly documented somewhere, but it has been hard for me to find an appropriate method. I tried append and merge but I am struggling to find an appropriate solution.

dataframe1:

     # Date Time, GMT-07:00  Crossflow (Cold) (Volts)  \
0        1           8:51:00 AM                   1.13431   
1        2           8:51:01 AM                   1.12821   
2        3           8:51:02 AM                   1.12943   
3        4           8:51:03 AM                   1.12759   
4        5           8:51:04 AM                   1.13065   
5        6           8:51:05 AM                   1.12821   
6        7           8:51:06 AM                   1.12943   
7        8           8:51:07 AM                   1.13065   
8        9           8:51:08 AM                   1.13126   
9       10           8:51:09 AM                   1.13126   
10      11           8:51:10 AM                   1.12821   

dataframe2:

         # Date Time, GMT-07:00  \
0        1           9:06:39 AM   
1        2           9:06:40 AM   
2        3           9:06:41 AM   
3        4           9:06:42 AM   
4        5           9:06:43 AM   
5        6           9:06:44 AM   
6        7           9:06:45 AM   
7        8           9:06:46 AM   
8        9           9:06:47 AM   
9       10           9:06:48 AM   
10      11           9:06:49 AM   
      K-Type, °C (LGR S/N: 10118625, SEN S/N: 10118625)  
0                                                 43.96  
1                                                 47.25  
2                                                 48.90  
3                                                 50.21  
4                                                 43.63  
5                                                 43.63  
6                                                 42.97  
7                                                 42.97  
8                                                 42.30  
9                                                 41.64  
10                                                40.98  

Upvotes: 0

Views: 1051

Answers (1)

blahblahblah
blahblahblah

Reputation: 2447

It appears that you want to append the dataframes to each other. Make sure that your date column has the same name in both dataframes otherwise pandas will treat them as two totally separate columns.

df = dataframe1.append(dataframe2, ignore_index=True)

Upvotes: 1

Related Questions