Reputation: 526
I have a database which contains 2 tables. I'd like to get all the data from both tables into single dataframe. In both tables there is a time column on which I'd like to sort the data after the combining.
df1=pd.read_sql("Select * from table1")
df2=pd.read_sql("Select * from table2")
What is the best way to combine df1 and df2 to a single dataframe ordered by time column?
Upvotes: 1
Views: 50
Reputation: 71580
Do you mean by concat
and sort_values
:
print(pd.concat([df1, df2]).sort_values('time'))
Upvotes: 1