From dbc44889d663ce501cb7067102570a3f65872bc4 Mon Sep 17 00:00:00 2001 From: luke-strange <92686634+luke-strange@users.noreply.github.com> Date: Thu, 6 Jun 2024 17:56:33 +0100 Subject: [PATCH] Add members and orgs on same file --- .../truenorth/analyse_members_list.ipynb | 307 ++++-------------- .../true-north/membership/_data/cumsum.csv | 21 ++ .../membership/_data/cumsum_members.csv | 21 -- src/themes/true-north/membership/index.vto | 26 +- 4 files changed, 106 insertions(+), 269 deletions(-) create mode 100644 src/themes/true-north/membership/_data/cumsum.csv delete mode 100644 src/themes/true-north/membership/_data/cumsum_members.csv diff --git a/pipelines/truenorth/analyse_members_list.ipynb b/pipelines/truenorth/analyse_members_list.ipynb index fa14805..3c4039b 100644 --- a/pipelines/truenorth/analyse_members_list.ipynb +++ b/pipelines/truenorth/analyse_members_list.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 17, + "execution_count": 208, "metadata": {}, "outputs": [], "source": [ @@ -15,7 +15,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 209, "metadata": {}, "outputs": [], "source": [ @@ -24,7 +24,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 210, "metadata": {}, "outputs": [ { @@ -193,7 +193,7 @@ "freq 21 " ] }, - "execution_count": 19, + "execution_count": 210, "metadata": {}, "output_type": "execute_result" } @@ -204,7 +204,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 211, "metadata": {}, "outputs": [ { @@ -279,270 +279,99 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 212, "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", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
last_updatedCreate DateDo you feel the True North report identified the key challenges and opportunities facing the region?Are you interested in attending future True North events?Are you currently a B Corp or in the process of becoming a B Corp?Would you be interested in hearing more from Brabners about the B Corp process?Company nameCityIndustrysectorlocationWhich theme of the True North report do you most identify with and could support activity around?How would you like to be involved with the True North network?company_sizemonthmonth_formatted
112024-04-26 16:12:002022-01-28 11:00:00YesYesYesYesBrabners LLPLiverpoolLegal ServicesLegal, Tech, IPNaNInnovation and changeNaNNaN2022-01-28 11:00:002022-01
242024-04-09 14:00:002022-01-28 13:01:00YesYesYesYesBrabners LLPLiverpoolLegal ServicesReal estateNaNPeople, skills and the futureNaNNaN2022-01-28 13:01:002022-01
582024-01-23 14:11:002022-01-28 15:01:00YesYesYesNoBrabners LLPLiverpoolLegal ServicesLegalCumbria; West Yorkshire; Greater Manchester; M...Innovation and changeKeeping informed about the latest True North n...500-9992022-01-28 15:01:002022-01
882023-11-01 10:03:002022-01-31 20:01:00YesYesYesNoBrabners LLPLiverpoolLegal ServicesAgriculture and real estateNaNSustainable developmentNaNNaN2022-01-31 20:01:002022-01
22024-05-13 11:12:002022-03-15 11:01:00YesYesYesYesBrabners LLPLiverpoolLegal ServicesConstruction and EngineeringNaNPeople, skills and the futureNaNNaN2022-03-15 11:01:002022-03
\n", - "
" - ], - "text/plain": [ - " last_updated Create Date \\\n", - "11 2024-04-26 16:12:00 2022-01-28 11:00:00 \n", - "24 2024-04-09 14:00:00 2022-01-28 13:01:00 \n", - "58 2024-01-23 14:11:00 2022-01-28 15:01:00 \n", - "88 2023-11-01 10:03:00 2022-01-31 20:01:00 \n", - "2 2024-05-13 11:12:00 2022-03-15 11:01:00 \n", - "\n", - " Do you feel the True North report identified the key challenges and opportunities facing the region? \\\n", - "11 Yes \n", - "24 Yes \n", - "58 Yes \n", - "88 Yes \n", - "2 Yes \n", - "\n", - " Are you interested in attending future True North events? \\\n", - "11 Yes \n", - "24 Yes \n", - "58 Yes \n", - "88 Yes \n", - "2 Yes \n", - "\n", - " Are you currently a B Corp or in the process of becoming a B Corp? \\\n", - "11 Yes \n", - "24 Yes \n", - "58 Yes \n", - "88 Yes \n", - "2 Yes \n", - "\n", - " Would you be interested in hearing more from Brabners about the B Corp process? \\\n", - "11 Yes \n", - "24 Yes \n", - "58 No \n", - "88 No \n", - "2 Yes \n", - "\n", - " Company name City Industry sector \\\n", - "11 Brabners LLP Liverpool Legal Services Legal, Tech, IP \n", - "24 Brabners LLP Liverpool Legal Services Real estate \n", - "58 Brabners LLP Liverpool Legal Services Legal \n", - "88 Brabners LLP Liverpool Legal Services Agriculture and real estate \n", - "2 Brabners LLP Liverpool Legal Services Construction and Engineering \n", - "\n", - " location \\\n", - "11 NaN \n", - "24 NaN \n", - "58 Cumbria; West Yorkshire; Greater Manchester; M... \n", - "88 NaN \n", - "2 NaN \n", - "\n", - " Which theme of the True North report do you most identify with and could support activity around? \\\n", - "11 Innovation and change \n", - "24 People, skills and the future \n", - "58 Innovation and change \n", - "88 Sustainable development \n", - "2 People, skills and the future \n", - "\n", - " How would you like to be involved with the True North network? \\\n", - "11 NaN \n", - "24 NaN \n", - "58 Keeping informed about the latest True North n... \n", - "88 NaN \n", - "2 NaN \n", - "\n", - " company_size month month_formatted \n", - "11 NaN 2022-01-28 11:00:00 2022-01 \n", - "24 NaN 2022-01-28 13:01:00 2022-01 \n", - "58 500-999 2022-01-28 15:01:00 2022-01 \n", - "88 NaN 2022-01-31 20:01:00 2022-01 \n", - "2 NaN 2022-03-15 11:01:00 2022-03 " - ] - }, - "execution_count": 21, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ + "# convert the month column to a datetime object\n", "data['month'] = pd.to_datetime(data['Create Date'])\n", - "data['month_formatted'] = data['month'].apply(datetime.strftime, format='%Y-%m').sort_index(ascending=True)\n", - "monthly_members = pd.DataFrame(data['month_formatted'].value_counts(ascending=False)).reset_index()\n", - "data.sort_values(by='Create Date').head()" + "\n", + "#convert the item to a formatted value in yyyy-mm format.\n", + "data['month_formatted'] = data['month'].apply(datetime.strftime, format='%Y-%m').sort_index(ascending=True)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 213, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "# take the number of members and calculate the number that joined each month.\n", + "monthly_members = pd.DataFrame(data['month_formatted'].value_counts(ascending=False)).reset_index()" + ] }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 214, "metadata": {}, "outputs": [], "source": [ - "# monthly_members['decimal_date'] = monthly_members['month'].apply(lambda x: x[5:7])\n", - "# monthly_members['decimal_date']" + "monthly_orgs = data.drop_duplicates(subset='Company name', keep='last')\n", + "monthly_orgs = pd.DataFrame(monthly_orgs['month_formatted'].value_counts(ascending=False)).reset_index()" ] }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 215, "metadata": {}, "outputs": [], "source": [ - "monthly_members['timestamp'] = pd.to_datetime(monthly_members['month_formatted'], format='%Y-%m').astype(int) / 10**9\n", + "def decimal_date(data):\n", + " # make a unix timestamp column\n", + " data['timestamp'] = pd.to_datetime(data['month_formatted'], format='%Y-%m').astype(int) / 10**9\n", + " # make a decimal date and round to 2dp.\n", + " data['year'] = data['timestamp'].div((86400*365.25)).add(1970).round(2)\n", + " # drop the timestamp column\n", + " data.drop(columns='timestamp', inplace=True) \n", + " # set year and formatted month as the index so they aren't included in the cumsum.\n", + " data.set_index(['year', 'month_formatted'], inplace=True, append=True)\n", "\n", - "monthly_members['year'] = monthly_members['timestamp'].div((86400*365.25)).add(1970).round(2)" + " return data" + ] + }, + { + "cell_type": "code", + "execution_count": 216, + "metadata": {}, + "outputs": [], + "source": [ + "def calculate_cumsum(data, count_name):\n", + " # order by date, then do the cumsum. reset the index, drop the original index column as not needed\n", + " data = pd.DataFrame(data.sort_index(level=2).cumsum().reset_index().drop(columns='level_0'))\n", + " data.rename(columns={'count': f'{count_name}'}, inplace=True)\n", + " return data" + ] + }, + { + "cell_type": "code", + "execution_count": 217, + "metadata": {}, + "outputs": [], + "source": [ + "# apply above functions to data\n", + "cs_monthly_members = calculate_cumsum(decimal_date(monthly_members), count_name='individuals')\n", + "cs_monthly_orgs = calculate_cumsum(decimal_date(monthly_orgs), count_name='orgs')" + ] + }, + { + "cell_type": "code", + "execution_count": 218, + "metadata": {}, + "outputs": [], + "source": [ + "cs_merged = cs_monthly_members.merge(cs_monthly_orgs, how='inner', on=['year', 'month_formatted'])" ] }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 219, "metadata": {}, "outputs": [], "source": [ - "monthly_members.drop(columns='timestamp', inplace=True)\n", - "monthly_members.set_index(['year', 'month_formatted'], inplace=True, append=True)\n", - "cumsum = pd.DataFrame(monthly_members.sort_index(level=2).cumsum().reset_index().drop(columns='level_0'))\n", - "cumsum.to_csv(os.path.join(SRC_DIR,'themes/true-north/membership/_data/cumsum_members.csv'), index=False)" + "# write to file\n", + "# cs_monthly_members.to_csv(os.path.join(SRC_DIR,'themes/true-north/membership/_data/cumsum_members.csv'), index=False)\n", + "# cs_monthly_orgs.to_csv(os.path.join(SRC_DIR,'themes/true-north/membership/_data/cumsum_organisations.csv'), index=False)\n", + "cs_merged.to_csv(os.path.join(SRC_DIR,'themes/true-north/membership/_data/cumsum.csv'), index=False)" ] } ], diff --git a/src/themes/true-north/membership/_data/cumsum.csv b/src/themes/true-north/membership/_data/cumsum.csv new file mode 100644 index 0000000..d044a11 --- /dev/null +++ b/src/themes/true-north/membership/_data/cumsum.csv @@ -0,0 +1,21 @@ +year,month_formatted,individuals,orgs +2022.0,2022-01,4,1 +2022.16,2022-03,26,22 +2022.5,2022-07,28,23 +2022.58,2022-08,31,24 +2022.75,2022-10,33,26 +2022.91,2022-12,37,30 +2023.16,2023-03,39,32 +2023.33,2023-05,43,36 +2023.41,2023-06,46,38 +2023.49,2023-07,54,45 +2023.58,2023-08,64,55 +2023.66,2023-09,88,75 +2023.75,2023-10,140,123 +2023.83,2023-11,145,127 +2023.91,2023-12,153,134 +2024.0,2024-01,165,146 +2024.08,2024-02,171,151 +2024.16,2024-03,182,161 +2024.25,2024-04,186,164 +2024.33,2024-05,188,166 diff --git a/src/themes/true-north/membership/_data/cumsum_members.csv b/src/themes/true-north/membership/_data/cumsum_members.csv deleted file mode 100644 index 6d77791..0000000 --- a/src/themes/true-north/membership/_data/cumsum_members.csv +++ /dev/null @@ -1,21 +0,0 @@ -year,month_formatted,count -2022.0,2022-01,4 -2022.16,2022-03,26 -2022.5,2022-07,28 -2022.58,2022-08,31 -2022.75,2022-10,33 -2022.91,2022-12,37 -2023.16,2023-03,39 -2023.33,2023-05,43 -2023.41,2023-06,46 -2023.49,2023-07,54 -2023.58,2023-08,64 -2023.66,2023-09,88 -2023.75,2023-10,140 -2023.83,2023-11,145 -2023.91,2023-12,153 -2024.0,2024-01,165 -2024.08,2024-02,171 -2024.16,2024-03,182 -2024.25,2024-04,186 -2024.33,2024-05,188 diff --git a/src/themes/true-north/membership/index.vto b/src/themes/true-north/membership/index.vto index 64002df..2cd862b 100644 --- a/src/themes/true-north/membership/index.vto +++ b/src/themes/true-north/membership/index.vto @@ -3,23 +3,31 @@ title: Membership theme: true-north nicetheme: True North --- -

True North membership

-

The chart below shows the cumulative number of people that filled out the questionnaire required when joining the True North network

+

+ The chart below shows the cumulative number of members, and the cumulutive number of unique organisations, + in the True North network. In some months no one joined the network, so the data points are not evenly spaced. +

{{ comp.oi.chart.line({ config: { - data: cumsum_members, + data: cumsum, height: 600, legend: { show: true }, axis: { - x: { title: { label: "Date" }, grid: { 'stroke-dasharray': "6 2", 'stroke-width': "1"} }, - y: { title: { label: "Members" }, grid: { "stroke-width": "1"}, tick: { spacing: 50} } + x: { title: { label: "Date" }, grid: { show: true, 'stroke-dasharray': "6 2", 'stroke-width': "1" }, tick: { spacing: 1 } }, + y: { title: { label: "Members" }, grid: { show: false, "stroke-width": "1"}, tick: { spacing: 50} } }, series: [{ - title: "Members", + title: "Individuals", x: "year", - y: "count", - tooltip: "Members
{{ year }}: {{ _y }}" + y: "individuals", + tooltip: "Individuals
{{ year }}: {{ _y }}" + }, + { + title: "Organisations", + x: "year", + y: "orgs", + tooltip: "Organisations
{{ year }}: {{ _y }}" }] } }) -}} \ No newline at end of file +}}