I would like to calculate workers tips. Several workers worked on each transaction. I have 2 dataframes, ts_df (for transaction) and shift_df (for workers shift), to calculate the tip amount for each workes.
Transaction table example:
>>> ts_df.head()
Date Time tip
1 2021-03-01 09:00:39 2.40
2 2021-03-01 09:27:39 5.45
4 2021-03-01 09:54:50 2.00
5 2021-03-01 09:57:37 2.10
6 2021-03-01 10:35:56 2.57
>>> ts_df.dtypes
Date object
Time object
tip float64
dtype: object
Here is example of shift transaction:
>>> shift_df.head()
Date Clock_start Clock_end employee
0 2021-03-01 08:30:00 14:30:00 Jose
1 2021-03-01 09:30:00 15:30:00 April
2 2021-03-02 06:00:00 07:30:00 John
3 2021-03-02 08:30:00 14:30:00 Jose
4 2021-03-02 09:30:00 15:30:00 April
>>> shift_df.dtypes
Date object
Clock_start object
Clock_end object
employee object
dtype: object
All date and time objects are python date() and time() objects.
For example, Jose and April worked for the transaction[4] (4 2021-03-01 09:54:50 2.00). Jose and April should gets 1.00 each. What will be the best way?
Waht I am considering is that list of workers for the transaction can be added in a list to calculate the tip amount. Something like this:
In ts_df:
Date Time tip workers
1 2021-03-01 09:00:39 2.40 ['Jose']
2 2021-03-01 09:27:39 5.45 ['Jose']
4 2021-03-01 09:54:50 2.00 ['Jose', 'April']
5 2021-03-01 09:57:37 2.10 ['Jose', 'April']
6 2021-03-01 10:35:56 2.57 ['Jose', 'April']
Please teach me how to compare two independent tables to calculate worker's tip.
Thanks in advance!

