data: Merging Pandas DataFrame within a specific Date Range
I want to use pyjanitor referring this post but it doesn't give if merge with another columns at the same time.
Try
df_1.conditional_join(
... df_2,
... ("InvoiceDate ", "PromotionStart ", ">="),
... ("InvoiceDate ", "PromotionEnd ", "<=")
... )
output
+------------+-------------+---------------+-----------+
| LocationNo | InvoiceDate | InvoiceAmount | Promotion |
+------------+-------------+---------------+-----------+
| A | 01-Jul-20 | 79 | Yes |
+------------+-------------+---------------+-----------+
| B | 01-Jul-20 | 72 | |
+------------+-------------+---------------+-----------+
| C | 01-Jul-20 | 24 | |
+------------+-------------+---------------+-----------+
| A | 02-Jul-20 | 68 | Yes |
+------------+-------------+---------------+-----------+
| B | 02-Jul-20 | 6 | Yes |
+------------+-------------+---------------+-----------+
| C | 02-Jul-20 | 27 | |
+------------+-------------+---------------+-----------+
| A | 03-Jul-20 | 25 | |
+------------+-------------+---------------+-----------+
| B | 03-Jul-20 | 62 | Yes |
+------------+-------------+---------------+-----------+
| C | 03-Jul-20 | 58 | Yes |
+------------+-------------+---------------+-----------+
| D | 03-Jul-20 | 36 | Yes |
+------------+-------------+---------------+-----------+
| E | 03-Jul-20 | 65 | |
+------------+-------------+---------------+-----------+
| F | 03-Jul-20 | 81 | |
+------------+-------------+---------------+-----------+