Python Forum
Data merging & Timestamp - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: Data merging & Timestamp (/thread-29668.html)



Data merging & Timestamp - pandoori - Sep-15-2020

Hi,

New using Python, I can code simple stuff in several languages but I’m far from being an expert.
Here is my current situation:

I have 2 Dataframes:

DF1: (3 columns)

Timestamp (fred 10min) / A,B,C,D / Values
8/1/2020 0:10 / A / 26
8/1/2020 0:20 / A / 37
8/1/2020 0:20 / B / 54
8/1/2020 0:30 / B / 78


DF2 (10 columns)

A,B,C,D / Start date / End date / Other column 1 / Other column 2 / Other column n
A / 8/10/2020 11:32 / 8/1/2020 11:42 / To / Be / saved
A / 8/13/2020 0:20 / 8/15/2020 0:24 / To / Be / saved
B / 8/23/2020 0:23 / 8/23/2020 11:31 / To / Be / saved
B / 8/11/2020 15:20 / 8/1/2020 17:20 / To / Be / saved


I would like to
1. Create Timestamps (freq 10min) from the periods of time between ‘Start date’ and ‘End date’ in DF2
AND duplicate the values associated to the period of time (1 line before) to the newly created lines (1 line / time stamp (freq 10min))

Timestamp (fred 10min) / A,B,C,D / Other column 1 / Other column 2 / Other column n
8/10/2020 11:30 / A / To / Be / saved
8/10/2020 11:40 / A / To / Be / saved
8/13/2020 0:20 / B / TO / BE / SAVED
8/13/2020 0:30 / B / TO / BE / SAVED


2. Merge DF1 and DF2 (on Timestamp) to get

Timestamp (fred 10min) / A,B,C,D / Values / Other column 1 / Other column 2 / Other column n
8/10/2020 11:30 / A / 265 / To / Be / saved
8/10/2020 11:40 / A / 71 / To / Be / saved
8/1/2020 0:20 / B / 54 / / /
8/1/2020 0:20 / B / 78 / / /
8/13/2020 0:20 / B / 29 / TO / BE / SAVED
8/13/2020 0:30 / B / 83 / TO / BE / SAVED


To get those 2 DF I used panda but I quite stuck now...


RE: Data merging & Timestamp - Larz60+ - Sep-15-2020

please show what you have tried, and what the problem is, then we will be glad to help
you must make an effort first.