Data Science & Machine Learning 101

Data Science & Machine Learning 101

Share this post

Data Science & Machine Learning 101
Data Science & Machine Learning 101
Python & R: Merging Time Series Data
Copy link
Facebook
Email
Notes
More

Python & R: Merging Time Series Data

Rolling Forward Fill Merges in R and Python, and why you should do it too. Can also just use the function we build in there.

BowTied_Raptor's avatar
BowTied_Raptor
May 04, 2022
∙ Paid
3

Share this post

Data Science & Machine Learning 101
Data Science & Machine Learning 101
Python & R: Merging Time Series Data
Copy link
Facebook
Email
Notes
More
Share

Required Readings:

Time Series analysis & Lookahead Bias

R & Python Programming (libraries)

Data Wrangling

Table of Contents:

  1. Introduction

  2. Rolling Forward Data (Re-sampling)

  3. Merging Data

  4. Rolling Merges

1 - Introduction

You can download the GAP data here:
You can download the Unemployment data here:
You can download the CPI data here:

Sometimes, we will have to pull chunks of data from multiple locations, and then merge them together to make a new dataset. There are a few different ways to do it, this post will focus on: merging data, doing forward fills, and doing them together.

Hence the emphasis on time series merging.

2 - Rolling Forward Data (Re-sampling)

Notice the FRED economic data is in a monthly format, but the stock data is in a daily format. Now, since I just grabbed the data directly from FRED instead of using the app I developed, to make it fair, I need to roll the FRED data forward about 1 month (at least). In other words the Date Jan 1, 2021 becomes Jan 31, 2021.

This is also known as re-sampling the data.

The stock data on the other hand is available on a daily basis, so we won’t need to roll that one forward, and can just keep it as is.

Python

To handle this one easily, we will create a new column called Ceiling_Date. To

Keep reading with a 7-day free trial

Subscribe to Data Science & Machine Learning 101 to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 BowTied_Raptor
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share

Copy link
Facebook
Email
Notes
More