Added Front. A few script changes. Jupyter notebooks practice for customer analysis.
This commit is contained in:
409
Scripts/Jupyter/app_usage.ipynb
Normal file
409
Scripts/Jupyter/app_usage.ipynb
Normal file
@ -0,0 +1,409 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 59,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pandas as pd \n",
|
||||
"import numpy as np \n",
|
||||
"import seaborn as sns \n",
|
||||
"import matplotlib.pylab as plt \n",
|
||||
"import sketch\n",
|
||||
"plt.style.use('ggplot')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 60,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"pages = pd.read_csv(\"/Users/normrasmussen/Downloads/app_usage.csv\", index_col=0, header=0)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 61,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
" .dataframe tbody tr th:only-of-type {\n",
|
||||
" vertical-align: middle;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe tbody tr th {\n",
|
||||
" vertical-align: top;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe thead th {\n",
|
||||
" text-align: right;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<table border=\"1\" class=\"dataframe\">\n",
|
||||
" <thead>\n",
|
||||
" <tr style=\"text-align: right;\">\n",
|
||||
" <th></th>\n",
|
||||
" <th>Path</th>\n",
|
||||
" <th>Mar 13 - Apr 11</th>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>School Name</th>\n",
|
||||
" <th></th>\n",
|
||||
" <th></th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
" <tr>\n",
|
||||
" <th>Vivvix University for Ad Intel</th>\n",
|
||||
" <td>/courses</td>\n",
|
||||
" <td>25</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>Vivvix University for Ad Intel</th>\n",
|
||||
" <td>/previews</td>\n",
|
||||
" <td>16</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>Vivvix University for Ad Intel</th>\n",
|
||||
" <td>/account_links</td>\n",
|
||||
" <td>11</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>Vivvix University for Ad Intel</th>\n",
|
||||
" <td>/analytics</td>\n",
|
||||
" <td>8</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>Vivvix University for Ad Intel</th>\n",
|
||||
" <td>/settings/general/edit</td>\n",
|
||||
" <td>7</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>Vivvix University for Ad Intel</th>\n",
|
||||
" <td>/apps/integrations</td>\n",
|
||||
" <td>4</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>Vivvix University for Ad Intel</th>\n",
|
||||
" <td>/accounts/general/edit</td>\n",
|
||||
" <td>4</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>Vivvix University for Ad Intel</th>\n",
|
||||
" <td>/people</td>\n",
|
||||
" <td>3</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>Vivvix University for Ad Intel</th>\n",
|
||||
" <td>/settings/authentication</td>\n",
|
||||
" <td>3</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>Vivvix University for Ad Intel</th>\n",
|
||||
" <td>/styling/general/edit</td>\n",
|
||||
" <td>2</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"</div>"
|
||||
],
|
||||
"text/plain": [
|
||||
" Path Mar 13 - Apr 11\n",
|
||||
"School Name \n",
|
||||
" Vivvix University for Ad Intel /courses 25\n",
|
||||
" Vivvix University for Ad Intel /previews 16\n",
|
||||
" Vivvix University for Ad Intel /account_links 11\n",
|
||||
" Vivvix University for Ad Intel /analytics 8\n",
|
||||
" Vivvix University for Ad Intel /settings/general/edit 7\n",
|
||||
" Vivvix University for Ad Intel /apps/integrations 4\n",
|
||||
" Vivvix University for Ad Intel /accounts/general/edit 4\n",
|
||||
" Vivvix University for Ad Intel /people 3\n",
|
||||
" Vivvix University for Ad Intel /settings/authentication 3\n",
|
||||
" Vivvix University for Ad Intel /styling/general/edit 2"
|
||||
]
|
||||
},
|
||||
"execution_count": 61,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"pages.head(10)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 62,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
" .dataframe tbody tr th:only-of-type {\n",
|
||||
" vertical-align: middle;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe tbody tr th {\n",
|
||||
" vertical-align: top;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe thead th {\n",
|
||||
" text-align: right;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<table border=\"1\" class=\"dataframe\">\n",
|
||||
" <thead>\n",
|
||||
" <tr style=\"text-align: right;\">\n",
|
||||
" <th></th>\n",
|
||||
" <th>Total Views</th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"</div>"
|
||||
],
|
||||
"text/plain": [
|
||||
"Empty DataFrame\n",
|
||||
"Columns: [Total Views]\n",
|
||||
"Index: []"
|
||||
]
|
||||
},
|
||||
"execution_count": 62,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"pages_sum = pd.DataFrame(columns=['Total Views'])\n",
|
||||
"pages_sum.head()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 63,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
" .dataframe tbody tr th:only-of-type {\n",
|
||||
" vertical-align: middle;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe tbody tr th {\n",
|
||||
" vertical-align: top;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe thead th {\n",
|
||||
" text-align: right;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<table border=\"1\" class=\"dataframe\">\n",
|
||||
" <thead>\n",
|
||||
" <tr style=\"text-align: right;\">\n",
|
||||
" <th></th>\n",
|
||||
" <th>Total Views</th>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>School Name</th>\n",
|
||||
" <th></th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
" <tr>\n",
|
||||
" <th>Vivvix University for Ad Intel</th>\n",
|
||||
" <td>110</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>'@properties Academy</th>\n",
|
||||
" <td>322</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>4 Pillars Academy</th>\n",
|
||||
" <td>112</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>AIIM+</th>\n",
|
||||
" <td>528</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>ASAPP University</th>\n",
|
||||
" <td>153</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"</div>"
|
||||
],
|
||||
"text/plain": [
|
||||
" Total Views\n",
|
||||
"School Name \n",
|
||||
" Vivvix University for Ad Intel 110\n",
|
||||
"'@properties Academy 322\n",
|
||||
"4 Pillars Academy 112\n",
|
||||
"AIIM+ 528\n",
|
||||
"ASAPP University 153"
|
||||
]
|
||||
},
|
||||
"execution_count": 63,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"pages_sum['Total Views'] = pages.groupby(by='School Name')['Mar 13 - Apr 11'].sum()\n",
|
||||
"pages_sum.head(5)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 66,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
" .dataframe tbody tr th:only-of-type {\n",
|
||||
" vertical-align: middle;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe tbody tr th {\n",
|
||||
" vertical-align: top;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe thead th {\n",
|
||||
" text-align: right;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<table border=\"1\" class=\"dataframe\">\n",
|
||||
" <thead>\n",
|
||||
" <tr style=\"text-align: right;\">\n",
|
||||
" <th></th>\n",
|
||||
" <th>Total Views</th>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>School Name</th>\n",
|
||||
" <th></th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
" <tr>\n",
|
||||
" <th>Vivvix for Ad Intel</th>\n",
|
||||
" <td>110</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>'@properties</th>\n",
|
||||
" <td>322</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>4 Pillars</th>\n",
|
||||
" <td>112</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>AIIM+</th>\n",
|
||||
" <td>528</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>ASAPP</th>\n",
|
||||
" <td>153</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>| AgencyBloc</th>\n",
|
||||
" <td>3373</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>Académie Évolupharma</th>\n",
|
||||
" <td>253</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>Access</th>\n",
|
||||
" <td>11</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>ActiveLearner</th>\n",
|
||||
" <td>1907</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>Ad Intel</th>\n",
|
||||
" <td>2</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"</div>"
|
||||
],
|
||||
"text/plain": [
|
||||
" Total Views\n",
|
||||
"School Name \n",
|
||||
" Vivvix for Ad Intel 110\n",
|
||||
"'@properties 322\n",
|
||||
"4 Pillars 112\n",
|
||||
"AIIM+ 528\n",
|
||||
"ASAPP 153\n",
|
||||
" | AgencyBloc 3373\n",
|
||||
"Académie Évolupharma 253\n",
|
||||
"Access 11\n",
|
||||
"ActiveLearner 1907\n",
|
||||
"Ad Intel 2"
|
||||
]
|
||||
},
|
||||
"execution_count": 66,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"to_remove = ['Academy', 'academy', 'University', 'university', 'school', 'School', 'Sandbox', 'Knowledge Base']\n",
|
||||
"for item in pages_sum.itertuples(index=True):\n",
|
||||
" for word in to_remove:\n",
|
||||
" if word in item[0]:\n",
|
||||
" less = item[0].replace(word, '')\n",
|
||||
" pages_sum.rename(index={item[0]:less}, inplace=True)\n",
|
||||
"\n",
|
||||
"pages_sum.head(10)\n",
|
||||
" # if any(element in item[0] for element in to_remove):\n",
|
||||
" # print(item[0])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "jupyter",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.1"
|
||||
},
|
||||
"orig_nbformat": 4
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
0
Scripts/Jupyter/cust_arr_usage.ipynb
Normal file
0
Scripts/Jupyter/cust_arr_usage.ipynb
Normal file
@ -54,17 +54,15 @@
|
||||
" <thead>\n",
|
||||
" <tr style=\"text-align: right;\">\n",
|
||||
" <th></th>\n",
|
||||
" <th>Unnamed: 0</th>\n",
|
||||
" <th>Usage Month</th>\n",
|
||||
" <th>Unnamed: 2</th>\n",
|
||||
" <th>2020-05</th>\n",
|
||||
" <th>2020-06</th>\n",
|
||||
" <th>2020-07</th>\n",
|
||||
" <th>2020-08</th>\n",
|
||||
" <th>2020-09</th>\n",
|
||||
" <th>2020-10</th>\n",
|
||||
" <th>2020-11</th>\n",
|
||||
" <th>...</th>\n",
|
||||
" <th>OrgID</th>\n",
|
||||
" <th>Organization</th>\n",
|
||||
" <th>Churn Date</th>\n",
|
||||
" <th>2022-01</th>\n",
|
||||
" <th>2022-02</th>\n",
|
||||
" <th>2022-03</th>\n",
|
||||
" <th>2022-04</th>\n",
|
||||
" <th>2022-05</th>\n",
|
||||
" <th>2022-06</th>\n",
|
||||
" <th>2022-07</th>\n",
|
||||
" <th>2022-08</th>\n",
|
||||
" <th>2022-09</th>\n",
|
||||
@ -80,118 +78,89 @@
|
||||
" <tbody>\n",
|
||||
" <tr>\n",
|
||||
" <th>0</th>\n",
|
||||
" <td>Billing ID</td>\n",
|
||||
" <td>Organization</td>\n",
|
||||
" <td>Churn Date</td>\n",
|
||||
" <td>Active Learner Count</td>\n",
|
||||
" <td>Active Learner Count</td>\n",
|
||||
" <td>Active Learner Count</td>\n",
|
||||
" <td>Active Learner Count</td>\n",
|
||||
" <td>Active Learner Count</td>\n",
|
||||
" <td>Active Learner Count</td>\n",
|
||||
" <td>Active Learner Count</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>Active Learner Count</td>\n",
|
||||
" <td>Active Learner Count</td>\n",
|
||||
" <td>Active Learner Count</td>\n",
|
||||
" <td>Active Learner Count</td>\n",
|
||||
" <td>Active Learner Count</td>\n",
|
||||
" <td>Active Learner Count</td>\n",
|
||||
" <td>Active Learner Count</td>\n",
|
||||
" <td>Active Learner Count</td>\n",
|
||||
" <td>Active Learner Count</td>\n",
|
||||
" <td>Active Learner Count</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>1</th>\n",
|
||||
" <td>30867753</td>\n",
|
||||
" <td>Aquent</td>\n",
|
||||
" <td>2023-04</td>\n",
|
||||
" <td>165</td>\n",
|
||||
" <td>111</td>\n",
|
||||
" <td>19</td>\n",
|
||||
" <td>14</td>\n",
|
||||
" <td>13</td>\n",
|
||||
" <td>14</td>\n",
|
||||
" <td>20</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>58</td>\n",
|
||||
" <td>38</td>\n",
|
||||
" <td>50</td>\n",
|
||||
" <td>50</td>\n",
|
||||
" <td>39</td>\n",
|
||||
" <td>36</td>\n",
|
||||
" <td>46</td>\n",
|
||||
" <td>46</td>\n",
|
||||
" <td>43</td>\n",
|
||||
" <td>27</td>\n",
|
||||
" <td>24</td>\n",
|
||||
" <td>43.0</td>\n",
|
||||
" <td>27.0</td>\n",
|
||||
" <td>24.0</td>\n",
|
||||
" <td>26</td>\n",
|
||||
" <td>22</td>\n",
|
||||
" <td>8</td>\n",
|
||||
" <td>10</td>\n",
|
||||
" <td>2</td>\n",
|
||||
" <td>8.0</td>\n",
|
||||
" <td>10.0</td>\n",
|
||||
" <td>2.0</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>1</th>\n",
|
||||
" <td>33375202</td>\n",
|
||||
" <td>BioLife Solutions, Inc.</td>\n",
|
||||
" <td>2023-04</td>\n",
|
||||
" <td>11</td>\n",
|
||||
" <td>7</td>\n",
|
||||
" <td>4</td>\n",
|
||||
" <td>11</td>\n",
|
||||
" <td>4</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>2</th>\n",
|
||||
" <td>47167388</td>\n",
|
||||
" <td>Artsy</td>\n",
|
||||
" <td>2023-01</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>4</td>\n",
|
||||
" <td>3</td>\n",
|
||||
" <td>4</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>10</td>\n",
|
||||
" <td>9</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>30867495</td>\n",
|
||||
" <td>ZyXel Communications Inc</td>\n",
|
||||
" <td>2023-04</td>\n",
|
||||
" <td>1</td>\n",
|
||||
" <td>1</td>\n",
|
||||
" <td>2</td>\n",
|
||||
" <td>1</td>\n",
|
||||
" <td>2</td>\n",
|
||||
" <td>4</td>\n",
|
||||
" <td>2</td>\n",
|
||||
" <td>2</td>\n",
|
||||
" <td>1.0</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" <td>1.0</td>\n",
|
||||
" <td>1.0</td>\n",
|
||||
" <td>NaN</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"<p>3 rows × 39 columns</p>\n",
|
||||
"</div>"
|
||||
],
|
||||
"text/plain": [
|
||||
" Unnamed: 0 Usage Month Unnamed: 2 2020-05 \n",
|
||||
"0 Billing ID Organization Churn Date Active Learner Count \\\n",
|
||||
"1 30867753 Aquent 2023-04 165 \n",
|
||||
"2 47167388 Artsy 2023-01 NaN \n",
|
||||
" OrgID Organization Churn Date 2022-01 2022-02 2022-03 \n",
|
||||
"0 30867753 Aquent 2023-04 58 38 50 \\\n",
|
||||
"1 33375202 BioLife Solutions, Inc. 2023-04 11 7 4 \n",
|
||||
"2 30867495 ZyXel Communications Inc 2023-04 1 1 2 \n",
|
||||
"\n",
|
||||
" 2020-06 2020-07 2020-08 \n",
|
||||
"0 Active Learner Count Active Learner Count Active Learner Count \\\n",
|
||||
"1 111 19 14 \n",
|
||||
"2 NaN NaN NaN \n",
|
||||
" 2022-04 2022-05 2022-06 2022-07 2022-08 2022-09 2022-10 2022-11 2022-12 \n",
|
||||
"0 50 39 36 46 46 43.0 27.0 24.0 26 \\\n",
|
||||
"1 11 4 NaN NaN NaN NaN NaN NaN NaN \n",
|
||||
"2 1 2 4 2 2 1.0 NaN NaN NaN \n",
|
||||
"\n",
|
||||
" 2020-09 2020-10 2020-11 ... \n",
|
||||
"0 Active Learner Count Active Learner Count Active Learner Count ... \\\n",
|
||||
"1 13 14 20 ... \n",
|
||||
"2 NaN NaN NaN ... \n",
|
||||
"\n",
|
||||
" 2022-07 2022-08 2022-09 \n",
|
||||
"0 Active Learner Count Active Learner Count Active Learner Count \\\n",
|
||||
"1 46 46 43 \n",
|
||||
"2 4 3 4 \n",
|
||||
"\n",
|
||||
" 2022-10 2022-11 2022-12 \n",
|
||||
"0 Active Learner Count Active Learner Count Active Learner Count \\\n",
|
||||
"1 27 24 26 \n",
|
||||
"2 NaN 10 9 \n",
|
||||
"\n",
|
||||
" 2023-01 2023-02 2023-03 \n",
|
||||
"0 Active Learner Count Active Learner Count Active Learner Count \\\n",
|
||||
"1 22 8 10 \n",
|
||||
"2 NaN 1 NaN \n",
|
||||
"\n",
|
||||
" 2023-04 \n",
|
||||
"0 Active Learner Count \n",
|
||||
"1 2 \n",
|
||||
"2 NaN \n",
|
||||
"\n",
|
||||
"[3 rows x 39 columns]"
|
||||
" 2023-01 2023-02 2023-03 2023-04 \n",
|
||||
"0 22 8.0 10.0 2.0 \n",
|
||||
"1 NaN NaN NaN NaN \n",
|
||||
"2 NaN 1.0 1.0 NaN "
|
||||
]
|
||||
},
|
||||
"execution_count": 3,
|
||||
@ -205,7 +174,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": 4,
|
||||
"id": "7a091590-9fc4-43fe-9188-53798e7e2e51",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
@ -227,85 +196,6 @@
|
||||
"cust_data = pd.read_csv(\"/Users/normrasmussen/Downloads/churned_analysis.csv\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"id": "65710689-a42a-41cf-983c-c1332af26b43",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div style=\"display:flex;flex-direction:row;justify-content:space-between;\">\n",
|
||||
" <pre style=\"width: 100%; white-space: pre-wrap;\" id=\"5f334dd4-40fd-4eee-8ca6-0941cadf2a63\">\n",
|
||||
"# Freeze the top two rows\n",
|
||||
"cust_data.iloc[:2, :].style.set_properties(**{'background-color': 'lightblue', 'color': 'black', 'border-color': 'white'})\n",
|
||||
"</pre>\n",
|
||||
" <button style=\"height: fit-content;\" onclick=\"navigator.clipboard.writeText(JSON.parse(atob(`IlxuIyBGcmVlemUgdGhlIHRvcCB0d28gcm93c1xuY3VzdF9kYXRhLmlsb2NbOjIsIDpdLnN0eWxlLnNldF9wcm9wZXJ0aWVzKCoqeydiYWNrZ3JvdW5kLWNvbG9yJzogJ2xpZ2h0Ymx1ZScsICdjb2xvcic6ICdibGFjaycsICdib3JkZXItY29sb3InOiAnd2hpdGUnfSlcbiI=`)))\">Copy</button>\n",
|
||||
" </div>"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.HTML object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"cust_data.sketch.howto(\"Freeze the top two rows\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"id": "39c664df-fb79-4d14-8212-8b67e2e4c0dd",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div style=\"display:flex;flex-direction:row;justify-content:space-between;\">\n",
|
||||
" <pre style=\"width: 100%; white-space: pre-wrap;\" id=\"b4fe0d05-513c-4de9-92b0-f81f3638dfe3\">\n",
|
||||
"# Get the list of columns\n",
|
||||
"cols = list(cust_data.columns)\n",
|
||||
"\n",
|
||||
"# Get the index of the Churn Date column\n",
|
||||
"churn_date_index = cols.index('Churn Date')\n",
|
||||
"\n",
|
||||
"# Get the value of the Churn Date column for each row\n",
|
||||
"churn_dates = cust_data['Churn Date'].tolist()\n",
|
||||
"\n",
|
||||
"# Iterate through each row in the dataframe\n",
|
||||
"for i, row in cust_data.iterrows():\n",
|
||||
" # Get the value of the Churn Date column for this row\n",
|
||||
" churn_date = churn_dates[i]\n",
|
||||
"\n",
|
||||
" # Get the index of the column with the same month/year as the Churn Date column\n",
|
||||
" col_index = cols.index(churn_date)\n",
|
||||
"\n",
|
||||
" # Reorganize the columns so that the last column is the one with the same month/year as the Churn Date column\n",
|
||||
" cust_data = cust_data[cols[:churn_date_index] + cols[col_index:] + cols[churn_date_index:col_index]]\n",
|
||||
"</pre>\n",
|
||||
" <button style=\"height: fit-content;\" onclick=\"navigator.clipboard.writeText(JSON.parse(atob(`IlxuIyBHZXQgdGhlIGxpc3Qgb2YgY29sdW1uc1xuY29scyA9IGxpc3QoY3VzdF9kYXRhLmNvbHVtbnMpXG5cbiMgR2V0IHRoZSBpbmRleCBvZiB0aGUgQ2h1cm4gRGF0ZSBjb2x1bW5cbmNodXJuX2RhdGVfaW5kZXggPSBjb2xzLmluZGV4KCdDaHVybiBEYXRlJylcblxuIyBHZXQgdGhlIHZhbHVlIG9mIHRoZSBDaHVybiBEYXRlIGNvbHVtbiBmb3IgZWFjaCByb3dcbmNodXJuX2RhdGVzID0gY3VzdF9kYXRhWydDaHVybiBEYXRlJ10udG9saXN0KClcblxuIyBJdGVyYXRlIHRocm91Z2ggZWFjaCByb3cgaW4gdGhlIGRhdGFmcmFtZVxuZm9yIGksIHJvdyBpbiBjdXN0X2RhdGEuaXRlcnJvd3MoKTpcbiAgICAjIEdldCB0aGUgdmFsdWUgb2YgdGhlIENodXJuIERhdGUgY29sdW1uIGZvciB0aGlzIHJvd1xuICAgIGNodXJuX2RhdGUgPSBjaHVybl9kYXRlc1tpXVxuXG4gICAgIyBHZXQgdGhlIGluZGV4IG9mIHRoZSBjb2x1bW4gd2l0aCB0aGUgc2FtZSBtb250aC95ZWFyIGFzIHRoZSBDaHVybiBEYXRlIGNvbHVtblxuICAgIGNvbF9pbmRleCA9IGNvbHMuaW5kZXgoY2h1cm5fZGF0ZSlcblxuICAgICMgUmVvcmdhbml6ZSB0aGUgY29sdW1ucyBzbyB0aGF0IHRoZSBsYXN0IGNvbHVtbiBpcyB0aGUgb25lIHdpdGggdGhlIHNhbWUgbW9udGgveWVhciBhcyB0aGUgQ2h1cm4gRGF0ZSBjb2x1bW5cbiAgICBjdXN0X2RhdGEgPSBjdXN0X2RhdGFbY29sc1s6Y2h1cm5fZGF0ZV9pbmRleF0gKyBjb2xzW2NvbF9pbmRleDpdICsgY29sc1tjaHVybl9kYXRlX2luZGV4OmNvbF9pbmRleF1dXG4i`)))\">Copy</button>\n",
|
||||
" </div>"
|
||||
],
|
||||
"text/plain": [
|
||||
"<IPython.core.display.HTML object>"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"cust_data.sketch.howto(\"Reorganize each organization so that the last column month/year matches the value in the Churn Date column\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
|
||||
Reference in New Issue
Block a user