Skip to main content

Rappi's Workforce Team Data Analytics and Forecasting

This Python package provides functionality for data analysis and forecasting for Rappi's Workforce Management (WFM) system.

Installation

You can install the package using pip:

pip install workforcerappi


# #The package includes functions for processing and preparing data for analysis.

# importar librerias
from workforcerappi import data_processing as dp, modeling, order_distribution as od
import pandas as pd

# definir parametros
month="Agosto"
startdate = "2024-03-01"
FEATURES = ['dayofweek', 'quarter', 'month', 'year', 'dayofyear', 'dayofmonth', 'weekofyear']
year_month="2024-08"
TARGET = "SS" # or "BR"
SERVICE_USER_TYPE="Users"
SERVICE="Customer Live Orders"
REGION="SS" # or "BR"
concurrencia = 2  # concurrencia del servicio
sla = 0.8  # nivel de servicio
meta_aht = 10  
date_range=['2023-01-01', '2024-05-31']  

# Read orders from Snowflake
df_ordered = dp.read_and_sort_orders(date_range)

#Read Special days from Snowflake and Preprocess it
special_days=dp.preprocess_special_dates(date_range)
df_filtered = dp.filter_special_dates(df_ordered, special_days)

# Pivot Orders
orders = dp.pivot_orders(df_filtered,REGION)
data = orders.set_index("FECHA")

#Split data into train and test sets
train, test = dp.split_train_test_data(data, startdate)

# Add features like month, day of the week, week of the year, etc. from date
train = dp.create_features(train)
test = dp.create_features(test)

X_train = train[FEATURES]
y_train = train[TARGET]
X_test = test[FEATURES]
y_test = test[TARGET]

# Train the model
model = modeling.train_xgboost_model(X_train, y_train, X_test, y_test)

# Make Predictions for next months
predictions = modeling.make_predictions(model, X_test)
test['prediction'] = predictions
predictions = dp.create_future_predictions(model, FEATURES, '2024-08-01','2024-08-31', 'D')
month_to_predict = predictions

# Create Forecasted Orders Distribution
ordenes_financieras = od.create_ordenes_financieras(df_ordered, month_to_predict, ordenes_aprobadas=None, REGION=REGION , year_month=year_month)

# Create Orders Curve 
curva_ordenes = od.create_curva_ordenes(df_ordered,REGION)
# plot orders curve
reporting.plot_orders_curve(curva_ordenes)
# PxQ forecasted orders by orders curve Distribution
df3 = od.distribute_orders(ordenes_financieras, curva_ordenes)
print(df3.head())

# ajustar dias de festividades
# valor_a_ajustar = 1.30
# df3.loc[df3["FECHA"] == "2024-08-07", "CO"] *= valor_a_ajustar

# Read Inflow, AHT, CR from Snowflake Database
inflow = dp.read_cr_aht(date_range)

# Distribute inflow by interval
result=od.distribute_inflow_intraday(inflow, df3, SERVICE_USER_TYPE, SERVICE, REGION)

# Distribute aht by interval
result2 = od.distribute_aht_intraday(inflow, df3, SERVICE_USER_TYPE, SERVICE,REGION, result, meta_aht)

# Calculate Headcount based in inflow,aht, sla and concurrency 
required_headcount_df = od.hc(result,result2,sla, concurrencia)
print(required_headcount_df.head(3))

# Calculate requered hours based in headcount 
od.required_hours(required_headcount_df)
print(required_hours.head(3))

# Get the costs for the bpo (costs_webhelp,costs_brm,costs_aec)
costs_webhelp=costs.costs_webhelp(budget, SERVICE, "Septiembre")

print("Done!")


# Reporting Module:

# Time series:
reporting.plot_time_series(df_ordered, 'FECHA','ORDERS')

#Orders Curve 
reporting.plot_general_orders_curve(df_ordered, 'INTERVALO', 'ORDERS')

#Proportion of Orders by Country
reporting.plot_proportion_of_orders_by_country(df_ordered, 'ORDERS', 'COUNTRY')

# Total Numbers of orders per country
reporting.plot_total_orders_per_country(df_ordered, 'COUNTRY','ORDERS')

# Plot raw data vs predictions on test data
reporting.plot_raw_data_vs_prediction(data,X_test,test,model)

# Plot raw data vs forecasted
reporting.plot_raw_data_vs_forecasted(data,month_to_predict)

License

This project is licensed under a private license by Rappi Inc. Unauthorized copying, distribution, or modification of this project, via any medium, is strictly prohibited. For more details, please contact the legal department at Rappi.

Contact Information

For licensing inquiries, please reach out to:

© 2024 Rappi Inc. Todos los derechos reservados

Release files for workforcerappi 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for workforcerappi 0.3.0
File Size Uploaded
workforcerappi-0.3.0.tar.gz 16.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for workforcerappi 0.3.0
File Interpreter ABI Platform
workforcerappi-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 34.4 kB

Release files / workforcerappi-0.3.0.tar.gz

Download URL workforcerappi-0.3.0.tar.gz
Size 16.8 kB
Tags Source
SHA-256 checksum
How to use checksums
04de82ce79dd8a548629708ac90095cdb1a14ec38bed27945e42df3326170df1
BLAKE2b-256 checksum
How to use checksums
f19e26dafe94a97a47d64748522dbc843bd085799fd30f1e1f0a1a59fbb5daab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.14

Release files / workforcerappi-0.3.0-py3-none-any.whl

Download URL workforcerappi-0.3.0-py3-none-any.whl
Size 17.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a68dad8556640cc1971c7ebaf3d68fbec3c5dd332935591e2c37cccef3df829b
BLAKE2b-256 checksum
How to use checksums
53f52f5176ebfe0d6ad5f7803235a7bd5f87b34b814255b884d6ffc34461ad11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.14

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page