Need a function or something similar written in Python to fill in two dummy variable columns. I have a dataframe with the schedules of individual employees across the span of 2 weeks. The first column...


Need a function or something similar written in Python to fill in two dummy variable columns.



I have a dataframe with the schedules of individual employees across the span of 2 weeks. The first column is unique employee Id and remaining Column headings are shown in the format DXX-XX so D01-09 would mean day 1, shift 9am-10am where a 1 would mean the employee worked that shift and a 0 would mean they did not work that shift (every day starts DXX-7 until DXX-21 then restarts to the next day).


I have a second dataframe with transaction information for the time period with information regarding the cashier and the time of the transaction. There are 2 blank columns in this dataframe Previous Day Dummy and Previous Week Dummy.


For the Previous Day Dummy. The goal is to record if an employee's schedule is exactly the same as the previous day (all 1s and 0s are the same) based on the date of the transaction. If it has, the dummy column should display 0 and if it is the same it should display 1. For the Previous Week Dummy, it should do this based on if the employee had the exact same schedule on the day that is a week prior to the transaction date.


The lengths of days are 15 hours so there are 15 columns before the next day starts.




Transaction, Store,cashier, nRegItme, nBulkItem, nItem, DiscDummy, CashbackDummy, nCoupon, ChangeDummy, GiftcardDummy, nReturn, Total, PaymentMethod, Terminal, Receipt, Invoice,StartDate,StartTime,EndDate,EndTime,TransTime,TransTimeInSec,PreDayDummy,PreWkDummy 1, (South),1618,2,0,2,0,0,0,1,0,0,$7.48 , Receipt Alias,6,67964, RS106067964, 01/01/2016, 07:20:35, 01/01/2016, 07:21:04, 0:00:29,29,0, 2, (South),1618,7,4,11,0,0,0,0,0,0,$53.94 , Debit Card,6,67965, RS106067965, 01/01/2016, 07:23:59, 01/01/2016, 07:25:51, 0:01:52,112, , 3, (South),1618,2,1,3,1,0,0,0,0,0,$4.55 , EBT/SNAP,6,67966, RS106067966, 01/01/2016, 07:26:19, 01/01/2016, 07:28:28, 0:02:09,129, , 4, (South),1618,3,1,4,0,0,0,0,0,0,$8.90 , Credit Card,6,67967, RS106067967, 01/01/2016, 07:42:48, 01/01/2016, 07:43:32, 0:00:44,44, , 5, (South),1618,0,1,1,0,0,0,1,0,0,$0.36 , Gift Card,6,67968, RS106067968, 01/01/2016, 07:57:39, 01/01/2016, 07:57:56, 0:00:17,17, , 6, (South),1618,1,1,2,0,0,0,0,0,0,$6.23 , Debit Card,6,67969, RS106067969, 01/01/2016, 07:59:48, 01/01/2016, 08:00:25, 0:00:37,37, , 7, (South),2138,3,2,5,0,0,0,0,0,0,$22.97 , Debit Card,5,64807, RS105064807, 01/01/2016, 08:00:47, 01/01/2016, 08:01:48, 0:01:01,61, , 8, (South),1618,4,4,8,0,0,0,0,0,0,$18.63 , Credit Card,6,67970, RS106067970, 01/01/2016, 08:07:26, 01/01/2016, 08:08:17, 0:00:51,51, , 9, (South),2138,7,0,7,1,0,0,0,0,0,$13.94 , Debit Card,5,64808, RS105064808, 01/01/2016, 08:07:49, 01/01/2016, 08:08:42, 0:00:53,53, , 10, (South),1618,0,1,1,1,0,1,0,0,0,$3.21 , Cash,6,67971, RS106067971, 01/01/2016, 08:08:34, 01/01/2016, 08:09:08, 0:00:34,34, , 11, (South),1618,3,1,4,0,0,1,0,0,0,$4.47 , Cash,6,67972, RS106067972, 01/01/2016, 08:10:11, 01/01/2016, 08:10:40, 0:00:29,29, , 12, (South),1618,2,0,2,0,0,0,0,0,0,$2.00 , Debit Card,6,67973, RS106067973, 01/01/2016, 08:18:39, 01/01/2016, 08:19:19, 0:00:40,40, , 13, (South),1618,2,0,2,1,0,0,0,0,0,$8.98 , Credit Card,6,67974, RS106067974, 01/01/2016, 08:19:37, 01/01/2016, 08:19:58, 0:00:21,21, , 14, (South),1618,2,0,2,0,0,0,0,0,0,$8.98 , Debit Card,6,67975, RS106067975, 01/01/2016, 08:20:09, 01/01/2016, 08:21:23, 0:01:14,74, , 15, (South),2138,1,0,1,1,0,1,0,0,0,$5.08 , Cash,5,64809, RS105064809, 01/01/2016, 08:21:39, 01/01/2016, 08:23:06, 0:01:27,87, , 16, (South),2138,7,10,17,1,0,0,0,0,0,$76.08 , Credit Card,5,64810, RS105064810, 01/01/2016, 08:32:32, 01/01/2016, 08:35:45, 0:03:13,193, , 17, (South),2138,2,0,2,0,0,0,0,0,0,$4.89 , Credit Card,5,64811, RS105064811, 01/01/2016, 08:36:09, 01/01/2016, 08:36:36, 0:00:27,27, , 18, (South),1618,2,1,3,0,0,0,0,0,0,$15.08 , Debit Card,6,67976, RS106067976, 01/01/2016, 08:42:27, 01/01/2016, 08:43:21, 0:00:54,54, , 19, (South),1618,2,0,2,0,0,0,0,0,0,$6.49 , Debit Card,6,67978, RS106067978, 01/01/2016, 08:48:06, 01/01/2016, 08:48:50, 0:00:44,44, , 20, (South),2138,7,6,13,0,0,0,0,0,0,$54.13 , Credit Card,5,64812, RS105064812, 01/01/2016, 08:57:59, 01/01/2016, 08:59:27, 0:01:28,88, , 21, (South),1618,1,0,1,0,0,1,0,0,0,$4.29 , Cash,6,67979, RS106067979, 01/01/2016, 09:01:08, 01/01/2016, 09:01:14, 0:00:06,6, , 22, (South),1618,1,1,2,0,0,0,0,0,0,$11.10 , Debit Card,6,67980, RS106067980, 01/01/2016, 09:10:11, 01/01/2016, 09:11:19, 0:01:08,68, , 23, (South),1618,2,0,2,0,0,1,0,0,0,$1.34 , Cash,6,67981, RS106067981, 01/01/2016, 09:12:07, 01/01/2016, 09:12:16, 0:00:09,9, , 24, (South),1618,0,1,1,1,0,1,0,0,0,$3.67 , Cash,6,67982, RS106067982, 01/01/2016, 09:16:30, 01/01/2016, 09:16:51, 0:00:21,21, , 25, (South),2079,3,0,3,1,0,1,0,0,0,$1.32 , Cash,4,59235, RS104059235, 01/01/2016, 09:19:43, 01/01/2016, 09:19:51, 0:00:08,8, , 26, (South),1618,2,0,2,1,0,1,0,0,0,$1.32 , Cash,6,67983, RS106067983, 01/01/2016, 09:19:25, 01/01/2016, 09:20:06, 0:00:41,41, , 27, (South),1618,4,4,8,0,0,1,0,0,0,$14.39 , Cash,6,67984, RS106067984, 01/01/2016, 09:20:46, 01/01/2016, 09:21:30, 0:00:44,44, , 28, (South),1618,0,3,3,0,0,0,0,0,0,$10.17 , Credit Card,6,67985, RS106067985, 01/01/2016, 09:24:06, 01/01/2016, 09:25:20, 0:01:14,74, , 29, (South),1618,2,1,3,0,0,1,0,0,0,$6.95 , Cash,6,67986, RS106067986, 01/01/2016, 09:25:50, 01/01/2016, 09:26:06, 0:00:16,16, , 30, (South),1618,5,0,5,0,0,0,0,0,0,$21.91 , Debit Card,6,67987, RS106067987, 01/01/2016, 09:27:13, 01/01/2016, 09:28:30, 0:01:17,77, , 31, (South),1618,2,0,2,1,0,1,0,0,0,$2.75 , Cash,6,67988, RS106067988, 01/01/2016, 09:33:47, 01/01/2016, 09:34:16, 0:00:29,29, , 32, (South),1618,3,2,5,0,1,1,0,0,0,$16.06 , Receipt Alias,6,67989, RS106067989, 01/01/2016, 09:34:44, 01/01/2016, 09:35:26, 0:00:42,42, , 33, (South),1618,2,0,2,1,0,1,0,0,0,$4.23 , Cash,6,67990, RS106067990, 01/01/2016, 09:35:49, 01/01/2016, 09:36:04, 0:00:15,15, , 34, (South),1618,1,0,1,1,0,0,0,0,0,$2.79 , Debit Card,6,67991, RS106067991, 01/01/2016, 09:36:19, 01/01/2016, 09:36:45, 0:00:26,26, , 35, (South),1618,1,0,1,0,0,1,0,0,0,$1.00 , Cash,6,67992, RS106067992, 01/01/2016, 09:37:03, 01/01/2016, 09:37:14, 0:00:11,11, , 36, (South),1618,3,0,3,0,0,1,0,0,0,$10.67 , Cash,6,67993, RS106067993, 01/01/2016, 09:37:46, 01/01/2016, 09:37:59, 0:00:13,13, , 37, (South),1618,1,0,1,1,0,1,0,0,0,$2.54 , Cash,6,67994, RS106067994, 01/01/2016, 09:38:25, 01/01/2016, 09:38:44, 0:00:19,19, , 38, (South),2138,0,1,1,1,0,1,0,0,0,$0.52 , Cash,5,64813, RS105064813, 01/01/2016, 09:43:06, 01/01/2016, 09:43:29, 0:00:23,23, , 39, (South),2138,3,1,4,0,0,0,0,0,0,$21.06 , Debit Card,5,64814, RS105064814, 01/01/2016, 09:49:50, 01/01/2016, 09:50:33, 0:00:43,43, , 40, (South),1618,11,1,12,0,0,0,1,2,0,$18.35 , Gift Card,6,67996, RS106067996, 01/01/2016, 09:49:00, 01/01/2016, 09:50:46, 0:01:46,106, , 41, (South),1618,3,0,3,0,0,1,1,1,0,$3.67 , Cash,6,67997, RS106067997, 01/01/2016, 09:50:58, 01/01/2016, 09:51:52, 0:00:54,54, , 42, (South),1618,3,7,10,0,0,0,0,0,0,$26.17 , Debit Card,6,67998, RS106067998, 01/01/2016, 09:52:12, 01/01/2016, 09:54:01, 0:01:49,109, , 43, (South),1618,2,0,2,0,0,1,0,0,0,$2.00 , Cash,6,67999, RS106067999, 01/01/2016, 09:54:22, 01/01/2016, 09:54:49, 0:00:27,27, , 44, (South),2138,2,1,3,0,0,0,0,0,0,$9.07 , Debit Card,5,64815, RS105064815, 01/01/2016, 09:55:55, 01/01/2016, 09:56:30, 0:00:35,35, , 45, (South),2138,5,3,8,0,0,0,0,0,0,$30.47 , Debit Card,5,64816, RS105064816, 01/01/2016, 09:56:56, 01/01/2016, 09:57:46, 0:00:50,50, , 46, (South),2138,2,0,2,1,0,0,0,0,0,$3.39 , House Charge,5,64817, RS105064817, 01/01/2016, 09:58:26, 01/01/2016, 09:58:59, 0:00:33,33, , 47, (South),1618,0,1,1,0,0,0,0,0,0,$16.47 , Credit Card,6,68000, RS106068000, 01/01/2016, 09:59:08, 01/01/2016, 09:59:31, 0:00:23,23, , 48, (South),2065,1,0,1,0,0,0,0,0,0,$3.29 , Debit Card,1,64828, RS101064828, 01/01/2016, 09:59:32, 01/01/2016, 09:59:59, 0:00:27,27, , 49, (South),1618,0,3,3,0,0,1,0,0,0,$5.69 , Cash,6,68001, RS106068001, 01/01/2016, 10:00:40, 01/01/2016, 10:00:59, 0:00:19,19, , 50, (South),2138,11,8,19,0,0,0,0,0,0,$105.92 , Debit Card,5,64818, RS105064818, 01/01/2016, 10:00:59, 01/01/2016, 10:03:51, 0:02:52,172, , 51, (South),2138,2,0,2,0,0,1,0,0,0,$3.00 , Cash,5,64819, RS105064819, 01/01/2016, 10:04:46, 01/01/2016, 10:04:56, 0:00:10,10, , 52, (South),1618,20,3,23,0,0,0,0,0,0,$76.37 , Credit Card,6,68002, RS106068002, 01/01/2016, 10:03:31, 01/01/2016, 10:06:34, 0:03:03,183, , 53, (South),1618,2,0,2,1,0,0,0,0,0,$4.06 , Receipt Alias,6,68003, RS106068003, 01/01/2016, 10:06:41, 01/01/2016, 10:07:14, 0:00:33,33, , 54, (South),1618,1,0,1
Feb 26, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here