{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "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\n", "df = pd.read_csv('churn.csv')\n", "\n", "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", "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", "def fix_dataset_label(k):\n", " parts = k.split('_')\n", " if \"term\" in parts:\n", " timeframe = timeframe_labels[parts[-2:].join(\" \")]\n", " name = parts[0:-2].join(\" \").title()\n", " else:\n", " timeframe = 'Lifetime'\n", " name = parts.join(\" \").title()\n", " return f\"{name}: {timeframe}\"\n", "\n", "def x_labels(categories):\n", " return [category_labels[cat] for cat in categories]\n", "\n", "def dataset_labels(columns):\n", " return [fix_dataset_label(col) for col in columns]" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | booking_forms_short_term | \n", "booking_forms_medium_term | \n", "booking_forms_long_term | \n", "
|---|---|---|---|
| category | \n", "\n", " | \n", " | \n", " |
| active-user | \n", "0.046701 | \n", "0.041571 | \n", "0.040686 | \n", "
| fair-trial | \n", "0.268002 | \n", "0.020303 | \n", "0.000271 | \n", "
| quick-exit | \n", "0.232673 | \n", "0.000000 | \n", "0.000000 | \n", "
| short-termer | \n", "0.290954 | \n", "0.082213 | \n", "0.029034 | \n", "