GetAround / app.py
Zbehel
Debugging
18e291f
Raw
History Blame Contribute Delete
2.6 kB
import streamlit as st
import pandas as pd
import plotly.express as px
# Charger les données
df = pd.read_excel('https://full-stack-assets.s3.eu-west-3.amazonaws.com/Deployment/get_around_delay_analysis.xlsx')
# Rename col time_delta_with_previous_rental_in_minutes & delay_at_checkout_in_minutes
df.rename(columns={'time_delta_with_previous_rental_in_minutes': 'delta'}, inplace=True)
df.rename(columns={'delay_at_checkout_in_minutes': 'delay'}, inplace=True)
df['late_checkin'] = df['delay'] > 0
# Titre du tableau de bord
st.title("Getaround Rentals Analysis")
# Description
st.markdown("""
In order to mitigate those issues we’ve decided to implement a minimum delay between two rentals. A car won’t be displayed in the search results if the requested checkin or checkout times are too close from an already booked rental.
It solves the late checkout issue but also potentially hurts Getaround/owners revenues: we need to find the right trade off.
Our Product Manager still needs to decide:
- threshold: how long should the minimum delay be?
- scope: should we enable the feature for all cars?, only Connect cars?
In order to help them make the right decision, they are asking you for some data insights. Here are the first analyses they could think of, to kickstart the discussion. Don’t hesitate to perform additional analysis that you find relevant.
""")
# Visualiser les données
fig = px.histogram(df, x='delta', title='Distribution of Delays Between Rentals')
st.plotly_chart(fig)
# Sélection du seuil et du scope
threshold = st.slider("Select the minimum delay threshold (in hours)", 0, 12, 2)
scope = st.selectbox("Select the scope", ["All cars", "Connect cars"])
# Filtrer les données en fonction du scope
if scope == "Connect cars":
df = df[df['checkin_type'] == 'connect']
# Calculer le pourcentage de réservations affectées
affected_rentals = df[df['delay'] <= threshold*60].shape[0]
total_rentals = df.shape[0]
share_affected_rentals = affected_rentals / total_rentals * 100
# Afficher les résultats
st.write(f"Percentage of rentals potentially affected by the feature: {share_affected_rentals:.2f}%")
# Analyser les retards
late_checkins = df[df['late_checkin'] == True].shape[0]
total_checkins = df.shape[0]
share_late_checkins = late_checkins / total_checkins * 100
st.write(f"Share of late check-ins: {share_late_checkins:.2f}%")
# Analyser les cas problématiques résolus
solved_cases = df[(df['delta'] < threshold*60) & (df['late_checkin'] == True)].shape[0]
st.write(f"Number of problematic cases solved by the feature: {solved_cases}")