Files
Gainsight/Scripts/Jupyter/page_views_cats.ipynb

391 lines
14 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"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": 35,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"School Name object\n",
"School Uuid object\n",
"Customer Id object\n",
"Path object\n",
"Apr 7 - 13 int64\n",
"dtype: object"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pageviews = pd.read_csv(\"/Users/normrasmussen/Documents/Work/Data/GraphQuery (4).csv\")\n",
"pageviews.dtypes"
]
},
{
"cell_type": "code",
"execution_count": 36,
"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>academy</th>\n",
" <th>academy_id</th>\n",
" <th>org_id</th>\n",
" <th>path</th>\n",
" <th>apr_week</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Compass Academy</td>\n",
" <td>dc62bd23-e093-49ff-9f85-b8e3d6dc9e34</td>\n",
" <td>49efbc2d-004a-4130-819a-2f5cdd59413f</td>\n",
" <td>/people</td>\n",
" <td>356</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>CHEK Institute</td>\n",
" <td>c2adf18f-9247-403f-9914-f9ce7d412d17</td>\n",
" <td>4d7e5559-a90f-4c1c-9de7-88d4495ae76a</td>\n",
" <td>/people</td>\n",
" <td>288</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>GenTech Associates Academy</td>\n",
" <td>d38a8181-f864-40cd-91da-b47b05f8bf69</td>\n",
" <td>8fe4e045-0882-4a7d-a695-1477f1aa32d7</td>\n",
" <td>/people</td>\n",
" <td>137</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>CTAA&amp;#39;s School</td>\n",
" <td>e79c2971-f7dd-4f7b-93b3-c3192c00824f</td>\n",
" <td>677b83a3-20d8-4073-9cfb-6a28c6d53b92</td>\n",
" <td>/people</td>\n",
" <td>136</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Solo Internal Training</td>\n",
" <td>72047a94-38c4-460e-90e2-2a3df5096852</td>\n",
" <td>c05d6a25-cc80-447a-9b85-7b222ad9e4fd</td>\n",
" <td>/media</td>\n",
" <td>129</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>118</th>\n",
" <td>Lighthouse by LJ Hooker Group</td>\n",
" <td>cb56a39f-b6a1-4c0a-893f-9e0e93fe6c24</td>\n",
" <td>7ccf4a79-c896-4865-95e4-dfe134119943</td>\n",
" <td>/instructor_led_trainings</td>\n",
" <td>32</td>\n",
" </tr>\n",
" <tr>\n",
" <th>119</th>\n",
" <td>Mark43 University</td>\n",
" <td>85e2acae-6a0b-4f1c-a3e1-dd113218321d</td>\n",
" <td>ea5c9708-73f9-4905-a759-7b68d0128206</td>\n",
" <td>/courses</td>\n",
" <td>32</td>\n",
" </tr>\n",
" <tr>\n",
" <th>120</th>\n",
" <td>Mizuno Academy</td>\n",
" <td>f61cd40c-6cbf-41b3-a797-78b923137c23</td>\n",
" <td>b99abead-4af0-487d-b8a4-d77b2c8dded4</td>\n",
" <td>/communications/emails/broadcast</td>\n",
" <td>32</td>\n",
" </tr>\n",
" <tr>\n",
" <th>121</th>\n",
" <td>Capstone Scholars Program</td>\n",
" <td>66f38581-27d9-4d9d-8134-edd09c87940a</td>\n",
" <td>abbe2201-8500-4067-aeaf-73fa99824784</td>\n",
" <td>/people</td>\n",
" <td>32</td>\n",
" </tr>\n",
" <tr>\n",
" <th>122</th>\n",
" <td>Garrett Virtual Academy</td>\n",
" <td>4f211014-bf83-4c8d-8779-d743777ca8cf</td>\n",
" <td>26370510-3f8a-4d3a-9808-3d7ba2388e97</td>\n",
" <td>/people/invite</td>\n",
" <td>32</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>123 rows × 5 columns</p>\n",
"</div>"
],
"text/plain": [
" academy academy_id \n",
"0 Compass Academy dc62bd23-e093-49ff-9f85-b8e3d6dc9e34 \\\n",
"1 CHEK Institute c2adf18f-9247-403f-9914-f9ce7d412d17 \n",
"2 GenTech Associates Academy d38a8181-f864-40cd-91da-b47b05f8bf69 \n",
"3 CTAA&#39;s School e79c2971-f7dd-4f7b-93b3-c3192c00824f \n",
"4 Solo Internal Training 72047a94-38c4-460e-90e2-2a3df5096852 \n",
".. ... ... \n",
"118 Lighthouse by LJ Hooker Group cb56a39f-b6a1-4c0a-893f-9e0e93fe6c24 \n",
"119 Mark43 University 85e2acae-6a0b-4f1c-a3e1-dd113218321d \n",
"120 Mizuno Academy f61cd40c-6cbf-41b3-a797-78b923137c23 \n",
"121 Capstone Scholars Program 66f38581-27d9-4d9d-8134-edd09c87940a \n",
"122 Garrett Virtual Academy 4f211014-bf83-4c8d-8779-d743777ca8cf \n",
"\n",
" org_id path \n",
"0 49efbc2d-004a-4130-819a-2f5cdd59413f /people \\\n",
"1 4d7e5559-a90f-4c1c-9de7-88d4495ae76a /people \n",
"2 8fe4e045-0882-4a7d-a695-1477f1aa32d7 /people \n",
"3 677b83a3-20d8-4073-9cfb-6a28c6d53b92 /people \n",
"4 c05d6a25-cc80-447a-9b85-7b222ad9e4fd /media \n",
".. ... ... \n",
"118 7ccf4a79-c896-4865-95e4-dfe134119943 /instructor_led_trainings \n",
"119 ea5c9708-73f9-4905-a759-7b68d0128206 /courses \n",
"120 b99abead-4af0-487d-b8a4-d77b2c8dded4 /communications/emails/broadcast \n",
"121 abbe2201-8500-4067-aeaf-73fa99824784 /people \n",
"122 26370510-3f8a-4d3a-9808-3d7ba2388e97 /people/invite \n",
"\n",
" apr_week \n",
"0 356 \n",
"1 288 \n",
"2 137 \n",
"3 136 \n",
"4 129 \n",
".. ... \n",
"118 32 \n",
"119 32 \n",
"120 32 \n",
"121 32 \n",
"122 32 \n",
"\n",
"[123 rows x 5 columns]"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pageviews = pageviews.rename(columns={\n",
" 'School Name':'academy',\n",
" 'School Uuid':'academy_id',\n",
" 'Customer Id':'org_id',\n",
" 'Path':'path',\n",
" 'Apr 7 - 13': 'apr_week',\n",
"})\n",
"pageviews.head(123)"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [],
"source": [
"# pageviews.apr_week = pageviews.apr_week.astype(int)\n",
"# pageviews.academy_id = pageviews.academy_id.astype('category').cat.codes\n",
"# pageviews.org_id = pageviews.org_id.astype('category').cat.codes\n",
"# pageviews['academy']=pageviews['academy'].astype('category').cat.codes\n",
"# pageviews['path']=pageviews['path'].astype('category').cat.codes\n",
"# pageviews.plot(kind='scatter', x='apr_week', y='path')"
]
},
{
"cell_type": "code",
"execution_count": 41,
"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></th>\n",
" <th>apr_week</th>\n",
" </tr>\n",
" <tr>\n",
" <th>academy</th>\n",
" <th>path</th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th rowspan=\"2\" valign=\"top\">Vivvix University for Ad Intel</th>\n",
" <th>/account_links</th>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>/courses</th>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"3\" valign=\"top\">'@properties Academy</th>\n",
" <th>/account_links</th>\n",
" <td>8</td>\n",
" </tr>\n",
" <tr>\n",
" <th>/courses</th>\n",
" <td>11</td>\n",
" </tr>\n",
" <tr>\n",
" <th>/groups</th>\n",
" <td>4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th rowspan=\"5\" valign=\"top\">ActiveLearner</th>\n",
" <th>/courses/cgivmko2/builder/activities/QNpmEsyHk</th>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>/courses/cgivmko2/builder/activities/Rh6JL0L9U</th>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>/courses/cgivmko2/builder/activities/T0kIBCfZt</th>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>/courses/cgivmko2/builder/activities/ZG38aHRFcX</th>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>/courses/cgivmko2/builder/activities/_Jtk3s0pt</th>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>100 rows × 1 columns</p>\n",
"</div>"
],
"text/plain": [
" apr_week\n",
"academy path \n",
" Vivvix University for Ad Intel /account_links 1\n",
" /courses 1\n",
"'@properties Academy /account_links 8\n",
" /courses 11\n",
" /groups 4\n",
"... ...\n",
"ActiveLearner /courses/cgivmko2/builder/activities/QNpmEsyHk 2\n",
" /courses/cgivmko2/builder/activities/Rh6JL0L9U 5\n",
" /courses/cgivmko2/builder/activities/T0kIBCfZt 5\n",
" /courses/cgivmko2/builder/activities/ZG38aHRFcX 1\n",
" /courses/cgivmko2/builder/activities/_Jtk3s0pt 1\n",
"\n",
"[100 rows x 1 columns]"
]
},
"execution_count": 41,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pageviews = pageviews.groupby(['academy', 'path']).agg({'apr_week':'sum'})\n",
"pageviews.head(100)"
]
},
{
"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
}