Issue
Given
Table1 (based on 5 minute timeframe, with boolean values in column "b" and "s"):
timestamp (=index) open close b s
2022-10-08 18:00:00 4.29 4.29 0 1
2022-10-08 18:05:00 4.30 4.36 1 0
2022-10-08 18:10:00 4.36 4.35 0 0
2022-10-08 18:15:00 4.34 4.37 0 0
2022-10-08 18:20:00 4.37 4.37 0 1
2022-10-08 18:25:00 4.36 4.37 0 0
2022-10-08 18:30:00 4.37 4.37 1 0
2022-10-08 18:35:00 4.38 4.39 0 0
2022-10-08 18:40:00 4.39 4.38 0 1
2022-10-08 18:45:00 4.39 4.38 0 0
Table2 (has no column "b" and "s" initial, but must be created with the value "1" at the same timestamp as in table1 and the rest filled with "0". The value in other columns needs to be kept and are different in both tables):
timestamp (=index) b s
2022-10-08 18:00:00 4.29 4.29 0 1 (-> from table1)
2022-10-08 18:01:00 4.29 4.29 0 0
2022-10-08 18:02:00 4.29 4.29 0 0
2022-10-08 18:03:00 4.29 4.29 0 0
2022-10-08 18:04:00 4.29 4.29 0 0
2022-10-08 18:05:00 4.29 4.29 1 0 (-> from table1)
2022-10-08 18:06:00 4.30 4.39 0 0
2022-10-08 18:07:00 4.38 4.40 0 0
2022-10-08 18:08:00 4.40 4.40 0 0
2022-10-08 18:09:00 4.41 4.36 0 0
2022-10-08 18:10:00 4.36 4.33 0 0
2022-10-08 18:11:00 4.34 4.34 0 0
2022-10-08 18:12:00 4.33 4.32 0 0
2022-10-08 18:13:00 4.32 4.33 0 0
2022-10-08 18:14:00 4.33 4.35 0 0
2022-10-08 18:15:00 4.34 4.34 0 0
2022-10-08 18:16:00 4.34 4.35 0 0
2022-10-08 18:17:00 4.35 4.36 0 0
2022-10-08 18:18:00 4.36 4.36 0 0
2022-10-08 18:19:00 4.36 4.37 0 0
2022-10-08 18:20:00 4.37 4.37 0 1 (-> from table1)
2022-10-08 18:21:00 4.38 4.37 0 0
2022-10-08 18:22:00 4.37 4.38 0 0
2022-10-08 18:23:00 4.38 4.38 0 0
2022-10-08 18:24:00 4.38 4.37 0 0
2022-10-08 18:25:00 4.36 4.37 0 0
2022-10-08 18:26:00 4.37 4.38 0 0
2022-10-08 18:27:00 4.38 4.37 0 0
2022-10-08 18:28:00 4.37 4.37 0 0
2022-10-08 18:29:00 4.37 4.37 0 0
2022-10-08 18:30:00 4.37 4.37 1 0 (-> from table1)
2022-10-08 18:31:00 4.37 4.37 0 0
2022-10-08 18:32:00 4.37 4.37 0 0
2022-10-08 18:33:00 4.37 4.37 0 0
2022-10-08 18:34:00 4.36 4.37 0 0
2022-10-08 18:35:00 4.37 4.37 0 0
2022-10-08 18:36:00 4.38 4.38 0 0
2022-10-08 18:37:00 4.39 4.39 0 0
2022-10-08 18:38:00 4.39 4.39 0 0
2022-10-08 18:39:00 4.39 4.39 0 0
2022-10-08 18:40:00 4.39 4.39 0 1 (-> from table1)
2022-10-08 18:41:00 4.39 4.39 0 0
2022-10-08 18:42:00 4.38 4.38 0 0
2022-10-08 18:43:00 4.39 4.37 0 0
2022-10-08 18:44:00 4.38 4.38 0 0
2022-10-08 18:45:00 4.39 4.38 0 0
So I need a solution to find the values (from b and s) from the 5m timeframe and "plot" them on the same timestamp on table2. I guess the fastest way is numpy
?
Solution
You could do update
tab2.update(tab1)
Answered By - BENY
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.