{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# Setup and initialization\n", "import pandas as pd\n", "import plotly.express as px\n", "import plotly.graph_objects as go\n", "import numpy as np\n", "\n", "# Load CSV file into a raw dataframe\n", "df = pd.read_csv('churn.csv')\n", "\n", "# Pull some quick stats\n", "category_totals = df.groupby('category').size()\n", "\n", "user_category_labels = {\n", " 'quick-exit': 'Free trial only',\n", " 'fair-trial': '74 day churn',\n", " 'short-termer': '6 month churn',\n", " 'active-user': 'No churn'\n", "}\n", "metric_timeframe_labels = {\n", " 'short term': 'During free trial',\n", " 'medium term': 'After trial, before 90 days',\n", " 'long term': 'After 90 days, first 6 months'\n", "}\n", "\n", "category_order = {\n", " 'category': list(user_category_labels.keys())\n", "}\n", "\n", "def metric_label(metric_key):\n", " parts = metric_key.split('_')\n", " if \"term\" in parts:\n", " timeframe = metric_timeframe_labels[\" \".join(parts[-2:])]\n", " name = \" \".join(parts[0:-2]).title()\n", " else:\n", " timeframe = 'Lifetime'\n", " name = parts.join(\" \").title()\n", " return f\"{name}: {timeframe}\"" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | category | \n", "bookings_short_term | \n", "bookings_medium_term | \n", "
|---|---|---|---|
| 0 | \n", "active-user | \n", "0.092517 | \n", "0.510879 | \n", "
| 1 | \n", "fair-trial | \n", "0.198971 | \n", "0.057390 | \n", "
| 2 | \n", "quick-exit | \n", "0.133663 | \n", "0.000000 | \n", "
| 3 | \n", "short-termer | \n", "0.271699 | \n", "0.355134 | \n", "