{ "cells": [ { "cell_type": "code", "execution_count": 24, "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": 25, "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": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pd.set_option('display.max_rows', 100)\n", "pageviews = pd.read_csv(\"/Users/normrasmussen/Documents/Work/Data/GraphQuery (4).csv\", index_col=None)\n", "pageviews.dtypes" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
academyacademy_idorg_idpathapr_week
0Compass Academydc62bd23-e093-49ff-9f85-b8e3d6dc9e3449efbc2d-004a-4130-819a-2f5cdd59413f/people356
1CHEK Institutec2adf18f-9247-403f-9914-f9ce7d412d174d7e5559-a90f-4c1c-9de7-88d4495ae76a/people288
2GenTech Associates Academyd38a8181-f864-40cd-91da-b47b05f8bf698fe4e045-0882-4a7d-a695-1477f1aa32d7/people137
3CTAA's Schoole79c2971-f7dd-4f7b-93b3-c3192c00824f677b83a3-20d8-4073-9cfb-6a28c6d53b92/people136
4Solo Internal Training72047a94-38c4-460e-90e2-2a3df5096852c05d6a25-cc80-447a-9b85-7b222ad9e4fd/media129
..................
118Lighthouse by LJ Hooker Groupcb56a39f-b6a1-4c0a-893f-9e0e93fe6c247ccf4a79-c896-4865-95e4-dfe134119943/instructor_led_trainings32
119Mark43 University85e2acae-6a0b-4f1c-a3e1-dd113218321dea5c9708-73f9-4905-a759-7b68d0128206/courses32
120Mizuno Academyf61cd40c-6cbf-41b3-a797-78b923137c23b99abead-4af0-487d-b8a4-d77b2c8dded4/communications/emails/broadcast32
121Capstone Scholars Program66f38581-27d9-4d9d-8134-edd09c87940aabbe2201-8500-4067-aeaf-73fa99824784/people32
122Garrett Virtual Academy4f211014-bf83-4c8d-8779-d743777ca8cf26370510-3f8a-4d3a-9808-3d7ba2388e97/people/invite32
\n", "

123 rows × 5 columns

\n", "
" ], "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'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": 26, "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": 14, "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": 23, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
apr_week
academypath
Vivvix University for Ad Intel/account_links1
/courses1
'@properties Academy/account_links8
/courses11
/groups4
/groups/2a09819b-a19a-4e87-91c6-8b50ee3c46f8/courses1
/groups/2a09819b-a19a-4e87-91c6-8b50ee3c46f8/edit1
/groups/2a09819b-a19a-4e87-91c6-8b50ee3c46f8/memberships8
/groups/2a09819b-a19a-4e87-91c6-8b50ee3c46f8/memberships/new3
/instructor_led_trainings11
\n", "
" ], "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", " /groups/2a09819b-a19a-4e87-91c6-8b50ee3c46f8/co... 1\n", " /groups/2a09819b-a19a-4e87-91c6-8b50ee3c46f8/edit 1\n", " /groups/2a09819b-a19a-4e87-91c6-8b50ee3c46f8/me... 8\n", " /groups/2a09819b-a19a-4e87-91c6-8b50ee3c46f8/me... 3\n", " /instructor_led_trainings 11" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#pageviews = pageviews.groupby(['academy', 'path']).agg({'apr_week':'sum'})\n", "#pageviews.head(10)" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
apr_week
academypath
Vivvix University for Ad Intel/account_links1
/courses1
'@properties Academy/account_links8
/courses11
/groups4
/groups/2a09819b-a19a-4e87-91c6-8b50ee3c46f8/courses1
/groups/2a09819b-a19a-4e87-91c6-8b50ee3c46f8/edit1
/groups/2a09819b-a19a-4e87-91c6-8b50ee3c46f8/memberships8
/groups/2a09819b-a19a-4e87-91c6-8b50ee3c46f8/memberships/new3
/instructor_led_trainings11
\n", "
" ], "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", " /groups/2a09819b-a19a-4e87-91c6-8b50ee3c46f8/co... 1\n", " /groups/2a09819b-a19a-4e87-91c6-8b50ee3c46f8/edit 1\n", " /groups/2a09819b-a19a-4e87-91c6-8b50ee3c46f8/me... 8\n", " /groups/2a09819b-a19a-4e87-91c6-8b50ee3c46f8/me... 3\n", " /instructor_led_trainings 11" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pageviews.reset_index\n", "pageviews.head(10)" ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0 True\n", "1 True\n", "2 True\n", "3 True\n", "4 False\n", " ... \n", "13861 True\n", "13862 True\n", "13863 False\n", "13864 False\n", "13865 False\n", "Name: path, Length: 13866, dtype: bool" ] }, "execution_count": 38, "metadata": {}, "output_type": "execute_result" } ], "source": [ "startswith_list = ('/courses', '/people', 'learning_paths', '/instructor_led_trainings', '/preview', '/groups', '/account_links')\n", "#for root in startswith_list:\n", "# pageviews.path.str.startswith(root, na=False)\n", " #pageviews['root'] = pageviews.path.apply(lambda x: root if pageviews.path.str.startswith(root, na=False) else 'None')\n", "\n", "pageviews.path.str.startswith(startswith_list)" ] }, { "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 }