I have two dataframes and I want to "combine them by a certains conditions". My first dataframe have average Sms(avgSms) of day of week(1=Sunday, 2=Monday, 3=Tuesday...) , hour and min:
df1:
I | Day_of_week | hour | min | AvgSms
#1 1 0 0 12
#2 1 0 30 20
#3 1 1 0 19
#4 1 1 30 11
#5 1 2 0 12
#6 1 2 30 7
... ... ... ... ....
#10 2 0 0 14
#11 2 0 30 20
#12 2 1 0 19
#13 2 1 30 11
... ... ... ... ....
#222 7 23 30 13
The second dataframe have time and sms, something like this:
df2: Time Sms
1 2012-01-01 00:00:00 10
2 2012-01-01 00:30:00 11
3 2012-01-01 01:00:00 13
4 2012-01-01 01:30:00 10
5 2012-01-01 02:00:00 7
6 2012-01-01 02:30:00 3
7 2012-01-01 03:00:00 3
8 2012-01-01 03:30:00 2
.......................
400 2015-12-31 23:30:00 16
I want to add to the dataframe 2, the respective avgSms of the dataframe1 depending on the variable time whether it is a second or third and x hour and y and min.
I want something like this:
Time Sms avg
1 2012-01-01 00:00:00 10 12 --> 2012-01-01 was Sunday=1, h=0 and min=0
2 2012-01-01 00:30:00 11 20
3 2012-01-01 01:00:00 13 19
4 2012-01-01 01:30:00 10 11
5 2012-01-01 02:00:00 7 ..
6 2012-01-01 02:30:00 3
7 2012-01-01 03:00:00 3
8 2012-01-01 03:30:00 2
.......................
400 2015-12-31 23:30:00 16