Home > front end >  Convert Datetime formats and merge two OHLC timeseries on pandas
Convert Datetime formats and merge two OHLC timeseries on pandas

Time:04-21

My Plan:

I have two different datasets with OHLC values, one representing the Weekly (1W) timeframes: weekly_df and the other representing the hourly (1H) timeframes hourly_df.

Here's what the two data frame looks like:

Here's how the two data frame looks like.

My goal is to merge the weekly OHLC values to the hourly df by using enter image description here

The Problem:

Once this is done, everything is now a string and when I try to convert it back to datetime, the 00:00:00 in the date column disappears:

enter image description here

Once this is done, I wanted to merge the data frames by the date and fill, so that all the hourly OHLC values in a given date also have a column displaying their weekly OHLC value. As of right now, this is not working as the merge only merges the dates common between he data frames and omits the rest:

enter image description here

If there is an easier way to do it? As most of the methods I have tried are returning an error.

The two data frame CSV files:

Incase you need to test it, here are the two CSV files: enter image description here

Do let me know if anyone else finds another way to solve this by keeping the original time. Cheers!

  • Related