Loading...

Free Python

How to Combine Two Timeseries Together Into Single Pandas DataFrame in Python

How to Combine Two Timeseries Together Into Single Pandas DataFrame in Python

Combining Timeseries DataFrames
From time to time, you may run into situations where you are going to want to combine timeseries from separate files into the same file. We will use data from FTX to combine hourly spot BTC/USDT timeseries with hourly BTC Perpetual futures data in the below code. The ability to combine timeseries on a common index (the timestamp) will open doors to other analysis and the creation of all new timeseries. The most key step is ensuring that the index is set properly. Data is loaded from our respective FTX page. We use Pandas Dataframes to 1) change the index 2) drop unimportant columns 3) rename our remaining column 4) join our timeseries together 5) add a human-readable date time to the dataframe

Live codebase Python