{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%load_ext autoreload\n",
    "%autoreload 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import plotnine as p9\n",
    "import sys\n",
    "\n",
    "sys.path.append(\"../\")\n",
    "from k8s_survey_analysis import prepare_2019\n",
    "\n",
    "pd.options.display.max_columns = 999\n",
    "from textwrap import wrap\n",
    "from k8s_survey_analysis.plot_utils import (\n",
    "    make_bar_chart,\n",
    "    make_likert_chart,\n",
    "    make_single_bar_chart,\n",
    "    make_single_likert_chart,\n",
    ")\n",
    "\n",
    "# Silence warnings from PlotNine, mostly about overwriting x_scales\n",
    "import warnings\n",
    "from plotnine.exceptions import PlotnineWarning\n",
    "\n",
    "warnings.filterwarnings(\"ignore\", category=PlotnineWarning)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Prepare data so the format is as compatible with the 2018 data as possible"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "survey_data = prepare_2019.get_df(\n",
    "    \"contribex-survey-2019.csv\"\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Examine response rates per  day"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    p9.ggplot(survey_data, p9.aes(x=\"date_taken\"))\n",
    "    + p9.geom_bar()\n",
    "    + p9.theme(axis_text_x=p9.element_text(angle=45, ha=\"right\"))\n",
    "    + p9.labs(x=\"Survey Date\", y=\"Number of Responses\", title=\"Responses Per Day\")\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The high spike seen on  1/13/20 aligns with the time when the survey was publicized on Twitter. To consider the potential effects of this, we examine how the response rate varied by various demographic information. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Examine response rates by contribution length, level and interest in next level"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "response_rates = (\n",
    "    survey_data.groupby([\"date_taken\", \"Contributing_Length\", \"Level_of_Contributor\"])\n",
    "    .count()\n",
    "    .reindex(\n",
    "        pd.MultiIndex.from_product(\n",
    "            [\n",
    "                survey_data[survey_data[y].notnull()][y].unique().tolist()\n",
    "                for y in [\"date_taken\", \"Contributing_Length\", \"Level_of_Contributor\"]\n",
    "            ],\n",
    "            names=[\"date_taken\", \"Contributing_Length\", \"Level_of_Contributor\"],\n",
    "        ),\n",
    "        fill_value=0,\n",
    "    )\n",
    "    .reset_index()\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "response_rates = response_rates.assign(\n",
    "    grp=response_rates.Contributing_Length.str.cat(response_rates.Level_of_Contributor)\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    p9.ggplot(response_rates,\n",
    "          p9.aes(x='factor(date_taken)',\n",
    "                 y='Respondent_ID',\n",
    "                 group='grp',\n",
    "                 linetype='Contributing_Length',\n",
    "                 color='Level_of_Contributor')) + \n",
    "    p9.geom_line() + \n",
    "    p9.labs(x='Survey Data',\n",
    "            linetype = \"Length of Contribution\", \n",
    "            color='Contributor Level', \n",
    "            y='Number of Responses') +\n",
    "    p9.theme(axis_text_x = p9.element_text(angle=45, ha='right'))\n",
    ")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The survey was advertised on Twitter, and two groups had the largest number of disproportionate responses. Those responses came from either contributors working on their membership, or users that have been contributing less than a year. The largest group is users that fall into both categories."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    p9.ggplot(survey_data, p9.aes(x=\"date_taken\", fill=\"factor(Contributing_Length)\"))\n",
    "    + p9.geom_bar()\n",
    "    + p9.theme(axis_text_x=p9.element_text(angle=45, ha=\"right\"))\n",
    "    + p9.labs(x=\"Survey Date\", y=\"Number of Responses\", title=\"Responses Per Day\", fill='Contributing Length')\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    p9.ggplot(\n",
    "        survey_data[survey_data[\"Level_of_Contributor\"].notnull()],\n",
    "        p9.aes(x=\"date_taken\", fill=\"factor(Level_of_Contributor)\"),\n",
    "    )\n",
    "    + p9.geom_bar()\n",
    "    + p9.theme(axis_text_x=p9.element_text(angle=45, ha=\"right\"))\n",
    "    + p9.labs(x=\"Survey Date\", y=\"Number of Responses\", title=\"Responses Per Day\", fill='Level of Contributor')\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    p9.ggplot(\n",
    "        survey_data[survey_data[\"Interested_in_next_level\"].notnull()],\n",
    "        p9.aes(x=\"date_taken\", fill=\"factor(Interested_in_next_level)\"),\n",
    "    )\n",
    "    + p9.geom_bar()\n",
    "    + p9.theme(axis_text_x=p9.element_text(angle=45, ha=\"right\"))\n",
    "    + p9.labs(x=\"Survey Date\", y=\"Number of Responses\", title=\"Responses Per Day\", fill=\"Interest in Next Level\")\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Univariate histograms\n",
    "\n",
    "In the following sections, we look at the rest of the demographic variables individually. This allows us to see who responded to the survey."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    p9.ggplot(survey_data, p9.aes(x=\"Contributing_Length\"))\n",
    "    + p9.geom_bar()\n",
    "    + p9.theme(axis_text_x=p9.element_text(angle=45))\n",
    "    + p9.scale_x_discrete(\n",
    "        limits=[\n",
    "            \"less than one year\",\n",
    "            \"one to two years\",\n",
    "            \"two to three years\",\n",
    "            \"3+ years\",\n",
    "        ]\n",
    "    )\n",
    "    + p9.ggtitle(\"Number of Contributors by Length of Contribution\")\n",
    "    + p9.xlab(\"Length of Contribution\")\n",
    "    + p9.ylab(\"Number of Contributors\")\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    p9.ggplot(\n",
    "        survey_data[survey_data[\"Level_of_Contributor\"].notnull()],\n",
    "        p9.aes(x=\"Level_of_Contributor\"),\n",
    "    )\n",
    "    + p9.geom_bar()\n",
    "    + p9.theme(axis_text_x=p9.element_text(angle=45, ha=\"right\"))\n",
    "    + p9.labs(\n",
    "        title=\"Number of Contributors by Contributor Level\",\n",
    "        x=\"Contributor Level\",\n",
    "        y=\"Number of Contributors\",\n",
    "    )\n",
    "    + p9.scale_x_discrete(labels=lambda x: [\"\\n\".join(wrap(label, 20)) for label in x])\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    p9.ggplot(\n",
    "        survey_data[survey_data[\"World_Region\"].notnull()], p9.aes(x=\"World_Region\")\n",
    "    )\n",
    "    + p9.geom_bar()\n",
    "    + p9.labs(\n",
    "        title=\"Number of Contributors by World Region\",\n",
    "        x=\"World Region\",\n",
    "        y=\"Number of Contributors\",\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    p9.ggplot(\n",
    "        survey_data[survey_data[\"Interested_in_next_level\"].notnull()],\n",
    "        p9.aes(x=\"Interested_in_next_level\"),\n",
    "    )\n",
    "    + p9.geom_bar()\n",
    "    + p9.theme(axis_text_x=p9.element_text(angle=45, ha=\"right\"))\n",
    "    + p9.labs(\n",
    "        title=\"Number of Contributors by Interest in Next Level\",\n",
    "        x=\"Interest in Next Level\",\n",
    "        y=\"Number of Contributors\",\n",
    "    )\n",
    "    + p9.scale_x_discrete(labels=lambda x: [\"\\n\".join(wrap(label, 20)) for label in x])\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    p9.ggplot(survey_data, p9.aes(x=\"Contribute_to_other_OSS\"))\n",
    "    + p9.geom_bar()\n",
    "    + p9.theme(axis_text_x=p9.element_text(angle=45, ha=\"right\"))\n",
    "    + p9.scale_x_discrete(\n",
    "        limits=[\"this is my first open source project!\", \"1 other\", \"2 or more\"]\n",
    "    )\n",
    "    + p9.ggtitle(\"Participation in Other Open Source Projects\")\n",
    "    + p9.xlab(\"Number of other OSS Projects\")\n",
    "    + p9.ylab(\"Number of Contributors\")\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "employer_support = (\n",
    "    p9.ggplot(survey_data, p9.aes(x=\"Upstream_supported_at_employer\"))\n",
    "    + p9.geom_bar()\n",
    "    + p9.theme(axis_text_x=p9.element_text(angle=45, ha=\"right\"))\n",
    "    + p9.labs(title=\"Support by Employer\", x=\"Support Level\", y=\"Count\")\n",
    ")\n",
    "employer_support"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2-Way Cross Tabulations\n",
    "\n",
    "Before we look at the relation between demographic data and questions of interest, we look at two-way cross tabulations in demographic data."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "pd.crosstab(survey_data.World_Region, survey_data.Level_of_Contributor)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "pd.crosstab(survey_data.Contributing_Length, survey_data.Level_of_Contributor).loc[\n",
    "    [\"less than one year\", \"one to two years\", \"two to three years\", \"three+ years\"]\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "pd.crosstab(survey_data.Contributing_Length, survey_data.Contribute_to_other_OSS).loc[\n",
    "    [\"less than one year\", \"one to two years\", \"two to three years\", \"three+ years\"],\n",
    "    [\"this is my first open source project!\", \"1 other\", \"2 or more\"],\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "pd.crosstab(\n",
    "    survey_data.Level_of_Contributor, survey_data.Upstream_supported_at_employer\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "pd.crosstab(\n",
    "    survey_data.Interested_in_next_level, survey_data.Upstream_supported_at_employer\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "pd.crosstab(survey_data.Contributing_Length, survey_data.Upstream_supported_at_employer)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "pd.crosstab(survey_data.World_Region, \n",
    "            survey_data.Contribute_to_other_OSS)[['this is my first open source project!','1 other','2 or more']]\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Most Important Project\n",
    "\n",
    "The following plots use offset stacked bar charts, showing the overall rankings of the most important project. They also display the specific distributions of rankings, for each choice."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_likert_chart(\n",
    "        survey_data,\n",
    "        \"Most_Important_Proj:\",\n",
    "        [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\"],\n",
    "        max_value=7,\n",
    "        sort_x=True,\n",
    "    )\n",
    "    + p9.labs(\n",
    "        x=\"Project\",\n",
    "        color=\"Ranking\",\n",
    "        fill=\"Ranking\",\n",
    "        y=\"\",\n",
    "        title=\"Distribution of Ranking of Most Important Projects\",\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Mentoring is the most important project, with very few respondents rating it negatively, followed by contributing to documentation. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_likert_chart(\n",
    "        survey_data,\n",
    "        \"Most_Important_Proj:\",\n",
    "        [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\"],\n",
    "        facet_by=[\"Level_of_Contributor\", \".\"],\n",
    "        max_value=7,\n",
    "        sort_x=True,\n",
    "    )\n",
    "    + p9.labs(\n",
    "        x=\"Project\",\n",
    "        y=\"\",\n",
    "        fill=\"Ranking\",\n",
    "        color=\"Ranking\",\n",
    "        title=\"Rankings of projects in order of importance (1-7) by Contributor Level\",\n",
    "    )\n",
    "    + p9.theme(strip_text_y=p9.element_text(margin={\"r\": 0.9, \"units\": \"in\"}))\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "It is reasonable to expect that different roles in Kubernetes may value different projects more highly. The plot above shows that for many issues and role, this is not true. Some items of note are while most groups rate Cleaning  up the OWNERS file as their least important, there is a clear trend for Subproject Owners and Reviewers to view this as more important, although a large portion of them still rate this low. Similarly Subproject Owners view mentoring as less important than other groups. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_likert_chart(\n",
    "        survey_data,\n",
    "        \"Most_Important_Proj:\",\n",
    "        [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\"],\n",
    "        facet_by=[\"Interested_in_next_level\", \".\"],\n",
    "        max_value=7,\n",
    "        sort_x=True,\n",
    "    )\n",
    "    + p9.labs(\n",
    "        title=\"Rankings of projects in order of importance (1-7) by Interest in Next Level\",\n",
    "        y=\"\",\n",
    "        x=\"Project\",\n",
    "        color=\"Ranking\",\n",
    "        fill=\"Ranking\",\n",
    "    )\n",
    "    + p9.theme(strip_text_y=p9.element_text(margin={\"r\": 0.9, \"units\": \"in\"}))\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Similarly to contributor roles, the interest in the next level does not appear to be a major factor in the ranking order. Mentoring is still very important to almost all levels of interest, with a minor exception being Subproject Owners. The group that stands out a bit are those who aren't interested in the next level, who value GitHub Management higher than some other projects. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_likert_chart(\n",
    "        survey_data,\n",
    "        \"Most_Important_Proj:\",\n",
    "        [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\"],\n",
    "        facet_by=[\"Contributing_Length\", \".\"],\n",
    "        max_value=7,\n",
    "        sort_x=True,\n",
    "    )\n",
    "    + p9.labs(\n",
    "        title=\"Rankings of projects in order of importance (1-7) by Length of Contribution\",\n",
    "        y=\"\",\n",
    "        x=\"Project\",\n",
    "        color=\"Ranking\",\n",
    "        fill=\"Ranking\",\n",
    "    )\n",
    "    + p9.theme(strip_text_y=p9.element_text(margin={\"r\": 0.9, \"units\": \"in\"}))\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Another interesting take away is that the most important projects do not vary widely across the length of contribution. Once again, Mentoring is the most important project across all demographics."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Analysis of Common Blockers\n",
    "\n",
    "In this section, we use offset stacked bar charts again. They visualize which blockers cause the most issues for contributors."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "blocker_ratings = list(\n",
    "    reversed(\n",
    "        [\n",
    "            \"A frequent blocker\",\n",
    "            \"Often a problem\",\n",
    "            \"Sometimes a problem\",\n",
    "            \"Rarely a problem\",\n",
    "            \"Not a problem\",\n",
    "        ]\n",
    "    )\n",
    ")\n",
    "\n",
    "\n",
    "(\n",
    "    make_likert_chart(survey_data, \"Blocker:\", blocker_ratings)\n",
    "    + p9.labs(\n",
    "        title=\"Common Blockers\", color=\"Severity\", fill=\"Severity\", x=\"Blocker\", y=\"\"\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The most frequent blocker across all contributors is debugging test failures, followed by finding issues to work on. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_likert_chart(survey_data,'Blocker:',\n",
    "                   blocker_ratings,\n",
    "                   ['Contributing_Length','.'],\n",
    "                   wrap_facets=True) + \n",
    "    p9.labs(x='Blocker',\n",
    "            y='',\n",
    "            fill='Rating',\n",
    "            color='Rating', \n",
    "            title='Common Blockers by Length of Contribution')  +\n",
    "    p9.theme(strip_text_y = p9.element_text(margin={'r':.9,'units':'in'}))\n",
    ")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "When we look at blockers, by the length of the contributor, we can see that contributors across all lengths have the most issues with debugging test failures. But, finding important issues varies across the groups. Below, we look closer at these two groups."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_single_likert_chart(survey_data,\n",
    "                          'Blocker:_Debugging_test_failures',\n",
    "                          'Contributing_Length',\n",
    "                          blocker_ratings) + \n",
    "    p9.labs(x='Contributing Length',\n",
    "            y='',\n",
    "            fill=\"Rating\",\n",
    "            color=\"Rating\",\n",
    "            title='Debugging Test Failures Blocker by Contribution Length') + \n",
    "    p9.scale_x_discrete(limits=['less than one year', 'one to two years', 'two to three years', '3+ years']) \n",
    "\n",
    ")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "When it comes to debugging, it is less of an issue for new contributors, most likely because they are not as focused on contributing code yet. After their first year, it becomes a larger issue, but slowly improves over time."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "( \n",
    "    make_single_likert_chart(survey_data,\n",
    "                           'Blocker:_Finding_appropriate_issues_to_work_on',\n",
    "                           'Contributing_Length',\n",
    "                           blocker_ratings) + \n",
    "    p9.labs(x='Contributing Length',\n",
    "            y='',\n",
    "            fill=\"Rating\",\n",
    "            color=\"Rating\",\n",
    "            title='Finding Issues to Work on Blocker by Length of Contribution') + \n",
    "    p9.scale_x_discrete(limits=['less than one year', \n",
    "                                'one to two years', \n",
    "                                'two to three years',\n",
    "                                '3+ years'])\n",
    ")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Looking at contributors that have trouble finding issues to work on there is a clear trend that the longer you are a Kubernetes contributor, the less of an issue this becomes, suggesting a continued effort is needed to surface good first issues, and make new contributors aware of them. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_likert_chart(survey_data,'Blocker:',\n",
    "                   blocker_ratings,\n",
    "                   ['Level_of_Contributor','.']) + \n",
    "    p9.labs(x='Blocker',\n",
    "            y='',\n",
    "            fill='Rating',\n",
    "            color='Rating',\n",
    "            title='Common Blockers by Contributor Level')  +\n",
    "    p9.theme(strip_text_y = p9.element_text(margin={'r':.9,'units':'in'}))\n",
    ")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "When we segment the contributors by level, we again see that debugging test failures is the largest blocker among all groups. Most blockers affect contributor levels in similar patterns. The one slight exception, though, is that Subproject Owners are the only cohort to not struggle with finding the right SIG."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_single_likert_chart(\n",
    "        survey_data,\n",
    "        \"Blocker:_Debugging_test_failures\",\n",
    "        \"Level_of_Contributor\",\n",
    "        blocker_ratings,\n",
    "    )\n",
    "    + p9.labs(\n",
    "        x=\"Contributor Level\",\n",
    "        y=\"\",\n",
    "        fill=\"Rating\",\n",
    "        color=\"Rating\",\n",
    "        title=\"Debugging Test Failures Blocker by Level of Contributor\",\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This in-depth view confirms that debugging test failures is an issue across all contributor levels, but is a larger issue for Subproject Owners and Approvers."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_likert_chart(\n",
    "        survey_data, \"Blocker:\", blocker_ratings, [\"Interested_in_next_level\", \".\"]\n",
    "    )\n",
    "    + p9.labs(\n",
    "        x=\"Blocker\",\n",
    "        y=\"\",\n",
    "        fill=\"Rating\",\n",
    "        color=\"Rating\",\n",
    "        title=\"Common Blockers by Interest in Next Level\",\n",
    "    )\n",
    "    + p9.theme(strip_text_y=p9.element_text(margin={\"r\": 0.9, \"units\": \"in\"}))\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "When we look at the spread of blockers across interest in the next level, we see that those are interested are the most likely to struggle finding the best issues to work on. In the plot below, this is shown in more detail."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "(\n",
    "    make_single_likert_chart(survey_data,\n",
    "                             'Blocker:_Finding_appropriate_issues_to_work_on',\n",
    "                             'Interested_in_next_level',\n",
    "                             blocker_ratings) + \n",
    "    p9.labs(x='Interest in next level',\n",
    "            y='Percent',fill=\"Rating\",\n",
    "            color=\"Rating\",\n",
    "            title='Finding Issues to Work on Blocker by Interest in the Next Level') \n",
    "    )\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "When we look at the spread of blockers across interest in the next level, we see that those are interested are the most likely to struggle finding the best issues to work on. In the plot below, this is shown in more detail."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Because it is expected that the large increase in Twitter users may have affected the results of the survey, we looked at the users who reported using Twitter as their primary source of news, and how they compared to those who didn't."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "survey_data.loc[:, \"Check_for_news:_@kubernetesio_twitter\"] = survey_data[\n",
    "    \"Check_for_news:_@kubernetesio_twitter\"\n",
    "].astype(str)\n",
    "\n",
    "(\n",
    "    make_single_likert_chart(\n",
    "        survey_data,\n",
    "        \"Blocker:_Debugging_test_failures\",\n",
    "        \"Check_for_news:_@kubernetesio_twitter\",\n",
    "        blocker_ratings,\n",
    "    )\n",
    "    + p9.labs(\n",
    "        x=\"Twitter Use\",\n",
    "        y=\"\",\n",
    "        fill=\"Rating\",\n",
    "        color=\"Rating\",\n",
    "        title=\"Debugging Test Failures Blocker by Twitter Use\",\n",
    "    )\n",
    "    + p9.scale_x_discrete(labels=[\"Doesn't Use Twitter\", \"Uses Twitter\"])\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Contributors who use Twitter as their primary source of news, about Kubernetes, are less likely to report struggling with debugging test failures. This is primarily because many Twitter users are newer ones.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_single_likert_chart(\n",
    "        survey_data,\n",
    "        \"Blocker:_Finding_appropriate_issues_to_work_on\",\n",
    "        \"Check_for_news:_@kubernetesio_twitter\",\n",
    "        blocker_ratings,\n",
    "    )\n",
    "    + p9.labs(\n",
    "        x=\"Twitter Use\",\n",
    "        y=\"\",\n",
    "        fill=\"Rating\",\n",
    "        color=\"Rating\",\n",
    "        title=\"Finding Issues Blocker by Twitter Use\",\n",
    "    )\n",
    "    + p9.scale_x_discrete(labels=[\"Doesn't Use Twitter\", \"Uses Twitter\"])\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Conversely, those who use Twitter do struggle to find Issues to Work on, again because most contributors who primarily use Twitter for their news tend to be new users."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## First Place News is Seen"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Convert back to an int after converting to a string for categorical views above\n",
    "survey_data.loc[:,'Check_for_news:_@kubernetesio_twitter'] = survey_data[\n",
    "    'Check_for_news:_@kubernetesio_twitter'].astype(int)\n",
    "\n",
    "(\n",
    "    make_bar_chart(survey_data,'Check_for_news:') + \n",
    "    p9.labs(title='Where Contributors See News First',\n",
    "            x='News Source',\n",
    "            y='Count')\n",
    ")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Most contributors are getting their news primarily from the official dev mailing list."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_bar_chart(\n",
    "        survey_data, \"Check_for_news:\", [\"Level_of_Contributor\", \".\"], proportional=True\n",
    "    )\n",
    "    + p9.labs(\n",
    "        title=\"Where Contributors See News First by Contributor Level\",\n",
    "        x=\"News Source\",\n",
    "        y=\"Proportion\",\n",
    "        fill=\"News Source\",\n",
    "    )\n",
    "    + p9.theme(strip_text_y=p9.element_text(margin={\"r\": 0.9, \"units\": \"in\"}))\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Looking across each level of the contributor ladder, most levels display the same patterns, with all groups primarily using the dev mailing list. The second most common source of news is the three Slack channels."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_bar_chart(\n",
    "        survey_data,\n",
    "        \"Check_for_news:\",\n",
    "        [\"Interested_in_next_level\", \".\"],\n",
    "        proportional=True,\n",
    "    )\n",
    "    + p9.labs(\n",
    "        title=\"Where Contributors See News First by Interest in Next Level\",\n",
    "        x=\"News Source\",\n",
    "        y=\"Proportion\",\n",
    "        fill=\"News Source\",\n",
    "    )\n",
    "    + p9.theme(strip_text_y=p9.element_text(margin={\"r\": 0.9, \"units\": \"in\"}))\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Looking at news sources by interest in next level, we can see that many people who aren't interested rely on the kubernetes-sig-contribex mailing list at a much higher proportion than the other groups. Those who are interested in the next level, either through mentoring or by themselves, tend to use Twitter more. But, this is likely an artifact of the survey being advertised on Twitter."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "When we look news use by the length of time, we see that compared to other groups, contributors who have been contributing for less than a year rely on the dev mailing list. They replace this with Twitter, and possibly Slack."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Twitter Users\n",
    "\n",
    "Because of the large increase in responses after the survey was advertised on Twitter, we pay special attention to what type of users list Twitter as their primary source of news."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_single_bar_chart(\n",
    "        survey_data[survey_data[\"Level_of_Contributor\"].notnull()],\n",
    "        \"Check_for_news:_@kubernetesio_twitter\",\n",
    "        \"Level_of_Contributor\",\n",
    "        proportionally=True,\n",
    "    )\n",
    "    + p9.labs(\n",
    "        title=\"Proportion of Contributors, by contributor level, who get news through Twitter First\",\n",
    "        y=\"Proportion\",\n",
    "        x=\"Contributor Level\",\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Of users who get their news primarily through Twitter, most are members, or those working on becoming members"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_single_bar_chart(\n",
    "        survey_data[survey_data[\"Level_of_Contributor\"].notnull()],\n",
    "        \"Check_for_news:_@kubernetesio_twitter\",\n",
    "        \"Contributing_Length\",\n",
    "        proportionally=True,\n",
    "    )\n",
    "    + p9.labs(\n",
    "        title=\"Proportion of Contributors, by contributor level, who get news through Twitter First\",\n",
    "        y=\"Proportion\",\n",
    "        x=\"Contributor Level\",\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Many contributors, who use Twitter as their primary news source, have been contributing for less than a year. There is also a large proportion of users who have been contributing for two to three years. It is unclear why this cohort appears to use Twitter in large numbers, compared to users who have been contributing for one to two years. It is also unclear that this cohort appears to use Twitter at a level proportionately greater to even new contributors. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### k/community Use"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "  make_single_bar_chart(survey_data[survey_data['Level_of_Contributor'].notnull()],\n",
    "                        'Check_for_news:_kubernetes/community_repo_in_GitHub_(Issues_and/or_PRs)',\n",
    "                        'Contributing_Length',proportionally=True) +\n",
    "  p9.scale_x_discrete(limits=['less than one year',\n",
    "                              'one to two years', \n",
    "                              'two to three years',\n",
    "                              '3+ years']) +\n",
    "  p9.labs(x='Length of Contribution',\n",
    "          y='Proportion',\n",
    "          title='Proportion of Contributors who Check k/community GitHub first')\n",
    ")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Of the contributors that rely on the k/community GitHub page, there are relatively equal proportions from all contributor length cohorts."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_single_bar_chart(\n",
    "        survey_data[survey_data[\"Level_of_Contributor\"].notnull()],\n",
    "        \"Check_for_news:_kubernetes/community_repo_in_GitHub_(Issues_and/or_PRs)\",\n",
    "        \"Level_of_Contributor\",\n",
    "        proportionally=True,\n",
    "    )\n",
    "    + p9.labs(\n",
    "        x=\"Contributor Level\",\n",
    "        y=\"Proportion\",\n",
    "        title=\"Proportion of Contributors who Check k/community GitHub first\",\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The distribution of contributors by their levels is an interesting mix, showing that both the highest and lowest levels of the ladder rely on the k/community GitHub. They rely on this more than the middle levels. This may be a way to connect the two communities, especially on issues of Mentoring support."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_single_bar_chart(\n",
    "        survey_data[survey_data[\"Level_of_Contributor\"].notnull()],\n",
    "        \"Check_for_news:_kubernetes/community_repo_in_GitHub_(Issues_and/or_PRs)\",\n",
    "        \"Level_of_Contributor\",\n",
    "        proportionally=True,\n",
    "        facet2=\"Contributing_Length\",\n",
    "    )\n",
    "    + p9.labs(\n",
    "        x=\"Contributor Level\",\n",
    "        y=\"Proportion\",\n",
    "        title=\"Proportion of Contributors who Check k/community GitHub first\",\n",
    "    )\n",
    "    + p9.theme(strip_text_y=p9.element_text(margin={\"r\": 1.15, \"units\": \"in\"}))\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The above plot shows the proportion of users in each bucket created by the two-way faceting, and so it can be a bit misleading. For example, 100% of users who have been contributing one to two years and do not know about the existence of the contributor ladder check k/community first. Using the cross-tabulations above, this is only four people. We can see that across all lengths of contributions, both members and those working on membership use the k/community page. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Analysis of Contribution Areas"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "(\n",
    "    make_bar_chart(survey_data,'Contribute:') + \n",
    "    p9.labs(x='Contribution',y='Count',title=\"Areas Contributed To\")\n",
    ")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As the Kubernetes community moves towards using more repositories to better organize the code, we can see that more\n",
    "contributions are being made in other repositories. Most of these are still under the Kuberentes project. Documentation is the second highest area of contributions."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_bar_chart(survey_data.query(\"Contributing_Length != 'less than one year'\"),'Contribute:') + \n",
    "    p9.labs(x='Contribution',y='Count',title=\"Areas Contributed To (Less than 1 year excluded)\")\n",
    ")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "When we exclude first year users, the pattern remains mostly the same, with Documentation being replaced as the second most commonly contributed area by code insides k8s/k8s."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_bar_chart(\n",
    "        survey_data,\n",
    "        \"Contribute:\",\n",
    "        facet_by=[\"Level_of_Contributor\", \".\"],\n",
    "        proportional=True,\n",
    "    )\n",
    "    + p9.labs(\n",
    "        x=\"Contribution\", y=\"Count\", title=\"Areas Contributed To\", fill=\"Contribution\"\n",
    "    )\n",
    "    + p9.theme(strip_text_y=p9.element_text(margin={\"r\": 0.8, \"units\": \"in\"}))\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The contribution areas vary by the user level on the ladder, with those working on membership. They are unaware that there is a ladder focusing more on documentation than the other levels. Unsurprisingly, a large proportion of those who do not know there is ladder, have not yet contributed."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_bar_chart(\n",
    "        survey_data,\n",
    "        \"Contribute:\",\n",
    "        facet_by=[\"Contributing_Length\", \".\"],\n",
    "        proportional=True,\n",
    "    )\n",
    "    + p9.labs(\n",
    "        x=\"Contribution\", y=\"Count\", title=\"Areas Contributed To\", fill=\"Contribution\"\n",
    "    )\n",
    "    + p9.theme(strip_text_y=p9.element_text(margin={\"r\": 0.8, \"units\": \"in\"}))\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Looking at contribution areas by length of time contributing, it is clear that the primary area that new contributors work with is documentation. Among no cohort is the largest area of contribution the core k8s/k8s repository, showing the ongoing organization effort is successful. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_bar_chart(\n",
    "        survey_data,\n",
    "        \"Contribute:\",\n",
    "        facet_by=[\"Upstream_supported_at_employer\", \".\"],\n",
    "        proportional=True,\n",
    "    )\n",
    "    + p9.labs(\n",
    "        title=\"Contributions Given Employer Support\",\n",
    "        x=\"Contribution\",\n",
    "        y=\"Count\",\n",
    "        fill=\"Contribution\",\n",
    "        color=\"Contribution\",\n",
    "    )\n",
    "    + p9.theme(strip_text_y=p9.element_text(margin={\"r\": 1.15, \"units\": \"in\"}))\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Contributors with employer support are more likely to contribute to the main repository, but a healthy portion of those without employer support, or with a complicated support situation, also contribute. The main areas that see less contributions from those without employer support are community development and plugin work."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_bar_chart(\n",
    "        survey_data.query(\"Contributing_Length != 'less than one year'\"),\n",
    "        \"Contribute:\",\n",
    "        facet_by=[\"Upstream_supported_at_employer\", \".\"],\n",
    "        proportional=True,\n",
    "    )\n",
    "    + p9.labs(\n",
    "        title=\"Contributions Given Employer Suppot (Less than 1 year excluded)\",\n",
    "        x=\"\",\n",
    "        y=\"Count\",\n",
    "        fill=\"Contribution\",\n",
    "        color=\"Contribution\",\n",
    "    )\n",
    "    + p9.theme(strip_text_y=p9.element_text(margin={\"r\": 1.15, \"units\": \"in\"}))\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Removing the new users, and repeating the analysis done above does, not change the overall distributions much."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Resource Use Analysis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "use_ratings = [\n",
    "    \"Every Day\",\n",
    "    \"Several Times a Week\",\n",
    "    \"Several Times a Month\",\n",
    "    \"Occasionally\",\n",
    "    \"Never\",\n",
    "]\n",
    "use_ratings.reverse()\n",
    "\n",
    "(\n",
    "    make_likert_chart(survey_data, \"Use_freq:\", use_ratings, max_is_high=True)\n",
    "    + p9.labs(\n",
    "        x=\"Resource\",\n",
    "        y=\"\",\n",
    "        color=\"Frequency\",\n",
    "        fill=\"Frequency\",\n",
    "        title=\"Resource Use Frequency\",\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Among all contributors, Slack and GitHub are the most frequently used resources, while dicuss.kubernetes.io and unofficial channels are almost never used. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_likert_chart(\n",
    "        survey_data,\n",
    "        \"Use_freq:\",\n",
    "        use_ratings,\n",
    "        [\"Contributing_Length\", \".\"],\n",
    "        max_is_high=True,\n",
    "    )\n",
    "    + p9.labs(\n",
    "        x=\"Resource\",\n",
    "        y=\"\",\n",
    "        color=\"Frequency\",\n",
    "        fill=\"Frequency\",\n",
    "        title=\"Resource Use Frequency\",\n",
    "    )\n",
    "    + p9.theme(strip_text_y=p9.element_text(margin={\"r\": 0.8, \"units\": \"in\"}))\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "When segmenting out the resource use by contribution length, the pattern stays roughly the same across all cohorts. Google Docs, which is used in more in administrative tasks, increases the longer a contributor is involved in the project."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_likert_chart(\n",
    "        survey_data,\n",
    "        \"Use_freq:\",\n",
    "        use_ratings,\n",
    "        [\"Interested_in_next_level\", \".\"],\n",
    "        max_is_high=True,\n",
    "    )\n",
    "    + p9.labs(\n",
    "        x=\"Resource\",\n",
    "        y=\"\",\n",
    "        color=\"Frequency\",\n",
    "        fill=\"Frequency\",\n",
    "        title=\"Resource Use Frequency\",\n",
    "    )\n",
    "    + p9.theme(strip_text_y=p9.element_text(margin={\"r\": 0.95, \"units\": \"in\"}))\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The use of resources, across interest in the next level, shows only one major difference between the groups. Contributors not interested in the next level tend to use GitHub discussions, much less than other groups."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_likert_chart(\n",
    "        survey_data,\n",
    "        \"Use_freq:\",\n",
    "        use_ratings,\n",
    "        [\"Level_of_Contributor\", \".\"],\n",
    "        max_is_high=True,\n",
    "    )\n",
    "    + p9.labs(\n",
    "        x=\"Resource\",\n",
    "        y=\"\",\n",
    "        color=\"Frequency\",\n",
    "        fill=\"Frequency\",\n",
    "        title=\"Resource Use Frequency\",\n",
    "    )\n",
    "    + p9.theme(strip_text_y=p9.element_text(margin={\"r\": 0.8, \"units\": \"in\"}))\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The level of the contributor on the ladder shows a large difference between those that use Google Groups and Mailing Lists, as well as those who use Google Docs, etc. The primary users of Zoom meetings tend to be Subproject Owners."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_single_likert_chart(\n",
    "        survey_data,\n",
    "        \"Use_freq:_Google_Groups/Mailing_Lists\",\n",
    "        \"Level_of_Contributor\",\n",
    "        use_ratings,\n",
    "        five_is_high=True,\n",
    "    )\n",
    "    + p9.labs(\n",
    "        title=\"Use of Google Groups\",\n",
    "        x=\"Level of Contributor\",\n",
    "        y=\"Percent\",\n",
    "        fill=\"Frequency\",\n",
    "        color=\"Frequency\",\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The largest group not using Google Groups are those who do not know that there is a contributor ladder. This suggests that advertising the group may lead to more people knowing about the very existence of a contributor ladder. Or, that the existence of the contributor ladder is discussed more on Google Groups, as compared to other channels."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_single_likert_chart(\n",
    "        survey_data,\n",
    "        \"Use_freq:_Google_Docs/Forms/Sheets,_etc_(meeting_agendas,_etc)\",\n",
    "        \"Contributing_Length\",\n",
    "        use_ratings,\n",
    "        five_is_high=True,\n",
    "    )\n",
    "    + p9.labs(\n",
    "        title=\"Use of Google Drive\",\n",
    "        x=\"Length of Contributions\",\n",
    "        y=\"Percent\",\n",
    "        fill=\"Frequency\",\n",
    "        color=\"Frequency\",\n",
    "    )\n",
    "    + p9.scale_x_discrete(\n",
    "        limits=[\n",
    "            \"less than one year\",\n",
    "            \"one to two years\",\n",
    "            \"two to three years\",\n",
    "            \"3+ years\",\n",
    "        ]\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The use of Google Drive, which is primarily used for administrative tasks, increases the longer a contributor is involved in the project, which is not a surprising outcome."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_single_likert_chart(survey_data,\n",
    "                             'Use_freq:_YouTube_recordings_(community_meetings,_SIG/WG_meetings,_etc.)',\n",
    "                             'Contributing_Length',\n",
    "                             use_ratings,\n",
    "                             five_is_high=True) + \n",
    "    p9.labs(title='Use of YouTube Recordings',\n",
    "            x='Length of Contributions',\n",
    "            y='Percent',\n",
    "            fill=\"Frequency\",\n",
    "            color='Frequency') +\n",
    "    p9.scale_x_discrete(limits=['less than one year', 'one to two years', 'two to three years', '3+ years'])   +\n",
    "    p9.ylim(-0.75,0.75)\n",
    ")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There is a slight tendency that the longer the contributor is involved in the project, the less they use YouTube. This is a very weak association, though, and hides the fact that most contributors across all lengths do not use YouTube."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_single_likert_chart(survey_data[survey_data['Interested_in_next_level'].notnull()],\n",
    "                             'Use_freq:_YouTube_recordings_(community_meetings,_SIG/WG_meetings,_etc.)',\n",
    "                             'Level_of_Contributor',\n",
    "                             use_ratings,\n",
    "                             five_is_high=True) + \n",
    "    p9.labs(title='Use of YouTube Recordings',\n",
    "            x='Interest in next level',\n",
    "            y='Percent',\n",
    "            fill=\"Frequency\",\n",
    "            color='Frequency') +\n",
    "    p9.ylim(-0.75,0.75)\n",
    ")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The one group that does tend to use the YouTube recording, at least a few times a month, are those working on membership. This suggests that the resources available on YouTube are helpful to a subset of the community."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Use of Help Wanted Labels"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "help_wanted = survey_data[\n",
    "    survey_data[\n",
    "        \"Do_you_use_the\\xa0Help_Wanted_and/or_Good_First_Issue_labels_on_issues_you_file_to_find_contributors\"\n",
    "    ].isna()\n",
    "    == False\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "help_plot = (\n",
    "    p9.ggplot(\n",
    "        help_wanted,\n",
    "        p9.aes(\n",
    "            x=\"Do_you_use_the\\xa0Help_Wanted_and/or_Good_First_Issue_labels_on_issues_you_file_to_find_contributors\",\n",
    "            fill=\"Do_you_use_the\\xa0Help_Wanted_and/or_Good_First_Issue_labels_on_issues_you_file_to_find_contributors\",\n",
    "        ),\n",
    "    )\n",
    "    + p9.geom_bar(show_legend=False)\n",
    "    + p9.theme(axis_text_x=p9.element_text(angle=45, ha=\"right\"))\n",
    "    + p9.labs(\n",
    "        x=\"Used Label\",\n",
    "        title=\"Use of Help Wanted and/or Good First Issue Labels\",\n",
    "        y=\"Count\",\n",
    "    )\n",
    ")\n",
    "help_plot"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A majority of users, across all demographics, make use of the Help Wanted and Good First Issue labels on GitHub."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    help_plot\n",
    "    + p9.facet_grid([\"Contributing_Length\", \".\"])\n",
    "    + p9.theme(\n",
    "        strip_text_y=p9.element_text(\n",
    "            angle=0, ha=\"left\", margin={\"r\": 1.2, \"units\": \"in\"}\n",
    "        )\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The relative proportions of contributors who use the labels does not change with the length of contribution. The one exception being that very few contributors, who have been doing so for 3+ years, don't use the labels."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    p9.ggplot(\n",
    "        help_wanted[help_wanted[\"Interested_in_next_level\"].notnull()],\n",
    "        p9.aes(\n",
    "            x=\"Do_you_use_the\\xa0Help_Wanted_and/or_Good_First_Issue_labels_on_issues_you_file_to_find_contributors\",\n",
    "            fill=\"Do_you_use_the\\xa0Help_Wanted_and/or_Good_First_Issue_labels_on_issues_you_file_to_find_contributors\",\n",
    "        ),\n",
    "    )\n",
    "    + p9.geom_bar(show_legend=False)\n",
    "    + p9.theme(axis_text_x=p9.element_text(angle=45, ha=\"right\"))\n",
    "    + p9.labs(\n",
    "        x=\"Used Label\",\n",
    "        title=\"Use of Help Wanted and/or Good First Issue Labels\",\n",
    "        y=\"Count\",\n",
    "    )\n",
    "    + p9.facet_grid(\n",
    "        [\"Interested_in_next_level\", \".\"],\n",
    "        labeller=lambda label: \"\\n\".join(wrap(label.replace(\"/\", \"/ \").strip(), 20)),\n",
    "    )\n",
    "    + p9.theme(\n",
    "        strip_text_y=p9.element_text(\n",
    "            angle=0, ha=\"left\", margin={\"r\": 1.2, \"units\": \"in\"}\n",
    "        )\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The plot above shows that these labels are especially helpful for those who are interested in the next level of the contributor ladder. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    help_plot\n",
    "    + p9.facet_grid(\n",
    "        [\"Level_of_Contributor\", \".\"],\n",
    "        labeller=lambda label: \"\\n\".join(wrap(label.replace(\"/\", \"/ \").strip(), 20)),\n",
    "    )\n",
    "    + p9.theme(\n",
    "        strip_text_y=p9.element_text(\n",
    "            angle=0, ha=\"left\", margin={\"r\": 1.34, \"units\": \"in\"}\n",
    "        )\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "When analyzing the help wanted labels across levels of the contributor ladder, most groups do not have a large majority class, indicating that this is not a variable that predicts the usefulness of the labels."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Interest in Mentoring"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "available_to_mentor = list(survey_data.columns)[-8]\n",
    "mentoring_interest = survey_data[survey_data[available_to_mentor].isna() == False]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "mentoring_plot = (\n",
    "    p9.ggplot(\n",
    "        mentoring_interest, p9.aes(x=available_to_mentor, fill=available_to_mentor)\n",
    "    )\n",
    "    + p9.geom_bar(show_legend=False)\n",
    "    + p9.theme(axis_text_x=p9.element_text(angle=45, ha=\"right\"))\n",
    "    + p9.labs(x=\"Interest\", title=\"Interest in Mentoring GSOC or Outreach\", y=\"Count\")\n",
    "    + p9.scale_x_discrete(\n",
    "        labels=lambda labels_list: [\n",
    "            \"\\n\".join(wrap(label.replace(\"/\", \"/ \").strip(), 30))\n",
    "            for label in labels_list\n",
    "        ]\n",
    "    )\n",
    ")\n",
    "mentoring_plot"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Most contributors feel that they do not have enough experience to mentor others, suggesting that more outreach can be done. This can make all but the newest contributors feel confident that they have something to offer."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    mentoring_plot\n",
    "    + p9.facet_grid([\"Upstream_supported_at_employer\", \".\"],\n",
    "                   labeller=lambda label: \"\\n\".join(wrap(label.replace(\"/\", \"/ \").strip(), 20)))\n",
    "    + p9.theme(strip_text_y=p9.element_text(angle=0, ha=\"left\")) \n",
    "    + p9.theme(\n",
    "        strip_text_y=p9.element_text(\n",
    "            angle=0, ha=\"left\", margin={\"r\": 1.34, \"units\": \"in\"}\n",
    "        )\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A majority of those who already mentor, as well as those who are interested in mentoring, have employers that support their work on Kubernetes. Those who have a complicated relationship with their employer are the only group to whom the most common response was not having enough time, or support."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    mentoring_plot\n",
    "    + p9.facet_grid(\n",
    "        [\"Interested_in_next_level\", \".\"],\n",
    "        labeller=lambda label: \"\\n\".join(wrap(label.replace(\"/\", \"/ \").strip(), 20)),\n",
    "    )\n",
    "    + p9.theme(\n",
    "        strip_text_y=p9.element_text(\n",
    "            angle=0, ha=\"left\", margin={\"r\": 1.34, \"units\": \"in\"}\n",
    "        )\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There is no clear pattern between the interest to mentor and interest in the next contributor level. The only exception is that those who want to mentor feel like they don't know enough to do so."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Participation in Meet our Contributors (MoC)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "moc_participation_name = list(survey_data.columns)[-9]\n",
    "moc_data = survey_data[survey_data[moc_participation_name].isna() == False]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "moc_plot = (\n",
    "    p9.ggplot(moc_data, p9.aes(x=moc_participation_name, fill=moc_participation_name))\n",
    "    + p9.geom_bar(show_legend=False)\n",
    "    + p9.theme(axis_text_x=p9.element_text(angle=45, ha=\"right\"))\n",
    "    + p9.labs(title=\"Watched or Participated in Meet Our Contributors\", x=\"\", y=\"Count\")\n",
    ")\n",
    "moc_plot"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Across all contributors, most do not know about the existence of Meet our Contributors."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    p9.ggplot(\n",
    "        moc_data[moc_data[\"Interested_in_next_level\"].notnull()],\n",
    "        p9.aes(x=moc_participation_name, fill=moc_participation_name),\n",
    "    )\n",
    "    + p9.geom_bar(show_legend=False)\n",
    "    + p9.facet_grid(\n",
    "        [\"Interested_in_next_level\", \".\"],\n",
    "        labeller=lambda label: \"\\n\".join(wrap(label.replace(\"/\", \"/ \").strip(), 20)),\n",
    "    )\n",
    "    + p9.theme(\n",
    "        strip_text_y=p9.element_text(\n",
    "            angle=0, ha=\"left\", margin={\"r\": 1.3, \"units\": \"in\"}\n",
    "        ),\n",
    "        axis_text_x=p9.element_text(angle=45, ha=\"right\"),\n",
    "    )\n",
    "    + p9.labs(\n",
    "        x=\"Watched MoC\",\n",
    "        title=\"Interest in next Level of the Contributor Ladder\\n compared to MoC Use\",\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Among all contributors who are interested in the next level of the ladder, most do still not know about MoC. This suggests a larger outreach would be useful, as most who do watch find it helpful."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    moc_plot\n",
    "    + p9.facet_grid(\n",
    "        [\"Level_of_Contributor\", \".\"],\n",
    "        labeller=lambda label: \"\\n\".join(wrap(label.replace(\"/\", \"/ \").strip(), 20)),\n",
    "    )\n",
    "    + p9.theme(\n",
    "        strip_text_y=p9.element_text(\n",
    "            angle=0, ha=\"left\", margin={\"r\": 1.34, \"units\": \"in\"}\n",
    "        )\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As before, across all cohorts of contributor levels, most do not know about MoC. But, for those who do watch it, they find it helpful. The only levels where more contributors know of it, compared to those that don't, are subproject owners and approvers.\n",
    "\n",
    "In the next series of plots, we analyze only those contributors who do not know about MoC. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    p9.ggplot(\n",
    "        moc_data[moc_data['Interested_in_next_level'].notnull() & \n",
    "                (moc_data[moc_participation_name] == \"no - didn't know this was a thing\")],\n",
    "        p9.aes(x='Interested_in_next_level', fill='Interested_in_next_level')) \n",
    "    + p9.geom_bar(show_legend=False) \n",
    "    + p9.facet_grid(\n",
    "        ['Level_of_Contributor','.'],\n",
    "        labeller=lambda label: \"\\n\".join(wrap(label.replace(\"/\", \"/ \").strip(), 20))\n",
    "    ) \n",
    "    + p9.theme(\n",
    "        strip_text_y = p9.element_text(\n",
    "            angle=0,ha='left',margin={\"r\": 1.3, \"units\": \"in\"}\n",
    "        ),\n",
    "        axis_text_x = p9.element_text(angle=45,ha='right')\n",
    "    ) \n",
    "    + p9.labs(\n",
    "        x = 'Interested in Next Level',\n",
    "        y = \"Count\", \n",
    "        title = \"Contributors who don't know about MoC\")\n",
    ")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Across all levels of the contributor ladder, many who are interested in the next level do not know about the existence of MoC. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    p9.ggplot(\n",
    "        moc_data[\n",
    "            (moc_data[moc_participation_name] == \"no - didn't know this was a thing\")\n",
    "        ],\n",
    "        p9.aes(x=\"Contributing_Length\", fill=\"Contributing_Length\"),\n",
    "    )\n",
    "    + p9.geom_bar(show_legend=False)\n",
    "    + p9.facet_grid(\n",
    "        [\"Level_of_Contributor\", \".\"],\n",
    "        labeller=lambda label: \"\\n\".join(wrap(label.replace(\"/\", \"/ \").strip(), 20)),\n",
    "    )\n",
    "    + p9.theme(\n",
    "        strip_text_y=p9.element_text(\n",
    "            angle=0, ha=\"left\", margin={\"r\": 1.34, \"units\": \"in\"}\n",
    "        ),\n",
    "        axis_text_x=p9.element_text(angle=45, ha=\"right\"),\n",
    "    )\n",
    "    + p9.labs(\n",
    "        x=\"Length of Contribution\",\n",
    "        y=\"Count\",\n",
    "        title=\"Contributors who don't know about MoC\",\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The plot above shows that a majority of those unaware, have not been contributors for very long. This is regardless of their level on the contributor ladder."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    p9.ggplot(\n",
    "        moc_data[\n",
    "            moc_data[\"Interested_in_next_level\"].notnull()\n",
    "            & (moc_data[moc_participation_name] == \"yes - it was helpful\")\n",
    "        ],\n",
    "        p9.aes(x=\"Interested_in_next_level\", fill=\"Interested_in_next_level\"),\n",
    "    )\n",
    "    + p9.geom_bar(show_legend=False)\n",
    "    + p9.facet_grid(\n",
    "        [\"Level_of_Contributor\", \".\"],\n",
    "        labeller=lambda label: \"\\n\".join(wrap(label.replace(\"/\", \"/ \").strip(), 20)),\n",
    "    )\n",
    "    + p9.theme(\n",
    "        strip_text_y=p9.element_text(\n",
    "            angle=0, ha=\"left\", margin={\"r\": 1.34, \"units\": \"in\"}\n",
    "        ),\n",
    "        axis_text_x=p9.element_text(angle=45, ha=\"right\"),\n",
    "    )\n",
    "    + p9.labs(\n",
    "        x=\"Interested in Next Level\",\n",
    "        y=\"Count\",\n",
    "        title=\"Contributors who watched or participated in \\n MoC and found it helpful\",\n",
    "    )\n",
    "    + p9.ylim(0, 15)  # Make the same scale as those who don't find it helpful\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The plot above shows that MoC is found useful by those who watch it. This is the case for those who have either attained the highest level on the ladder, or are interested in the next level. This holds true across all levels of the ladder. This suggests that MoC should not only cover information helpful to those trying to become members, but also those who wish to become approvers, reviewers, and subproject owners. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    p9.ggplot(\n",
    "        moc_data[(moc_data[moc_participation_name] == \"yes - it was helpful\")],\n",
    "        p9.aes(x=\"Contributing_Length\", fill=\"Contributing_Length\"),\n",
    "    )\n",
    "    + p9.geom_bar(show_legend=False)\n",
    "    + p9.facet_grid(\n",
    "        [\"Level_of_Contributor\", \".\"],\n",
    "        labeller=lambda label: \"\\n\".join(wrap(label.replace(\"/\", \"/ \").strip(), 20)),\n",
    "    )\n",
    "    + p9.theme(\n",
    "        strip_text_y=p9.element_text(\n",
    "            angle=0, ha=\"left\", margin={\"r\": 1.34, \"units\": \"in\"}\n",
    "        ),\n",
    "        axis_text_x=p9.element_text(angle=45, ha=\"right\"),\n",
    "    )\n",
    "    + p9.labs(\n",
    "        x=\"Length of Contribution\",\n",
    "        y=\"Count\",\n",
    "        title=\"Contributors who watched or participated in \\n MoC and found it helpful\",\n",
    "    )\n",
    "    + p9.ylim(0, 25)  # Make the same scale as those who don't find it helpful\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The majority of those who found MoC useful are contributors who are working towards their membership. This is suggesting that while most of the material might be geared towards them, the previous plot shows the importance of striking a balance between the two."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ways to Increase Attendance at Thursday Meetings"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "(\n",
    "    make_bar_chart(survey_data, \"Would_attend_if:\")\n",
    "    + p9.labs(x=\"Change\", y=\"Count\", title=\"Would attend if\")\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The primary reason contributors don't attend Thursday meetings is that they have too many meetings in their personal lives. As this is not something the Kubernetes community can control, we suggest they focus on the second most common suggestion: distributing a full agenda prior to the meeting. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_bar_chart(\n",
    "        survey_data,\n",
    "        \"Would_attend_if:\",\n",
    "        [\".\", \"Level_of_Contributor\"],\n",
    "        proportional=True,\n",
    "    )\n",
    "    + p9.labs(x=\"Change\", y=\"Count\", title=\"Would attend if\", fill=\"Change\")\n",
    "    + p9.theme(\n",
    "        strip_text_y=p9.element_text(angle=0, ha=\"left\", margin={\"r\": 1, \"units\": \"in\"})\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Across contributor levels, the dominant reason for their attendance would be \"fewer meetings in my personal schedule\". What is interesting is that for those who are not yet members, it is less of a dominating reason than other cohorts. These contributors give almost equal weight to many different changes, some of which may be appropriate to the Thursday meeting, but some of which may indicate the need for new types of outreach programming."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_bar_chart(\n",
    "        survey_data, \"Would_attend_if:\", [\".\", \"Contributing_Length\"], proportional=True\n",
    "    )\n",
    "    + p9.labs(x=\"Change\", y=\"Count\", title=\"Would attend if\", fill='Reason')\n",
    "    + p9.theme(\n",
    "        strip_text_y=p9.element_text(angle=0, ha=\"left\", margin={\"r\": 1, \"units\": \"in\"})\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Segmenting the contributors, by their length of contribution, does not reveal any patterns that are widely different than when looking at all the contributors as a whole."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_single_bar_chart(survey_data[survey_data['World_Region'].notnull()],\n",
    "                          'Would_attend_if:_Different_timeslot_for_the_meeting', \n",
    "                          'World_Region',\n",
    "                          proportionally=True\n",
    "                  ) + \n",
    "    p9.labs(x='Change',\n",
    "            y='Count',\n",
    "            title=\"Would attend if\")\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "When looking at the distribution of contributors, who would attend the meetings if they were held at a different time, we can see a large impact that location has. While the number of contributors located in Oceania and Africa is small, it makes forming significant conclusions more difficult. There are many contributors from Asia, indicating that the timing of the meetings is a major barrier to a large portion. This is simply because of the timezones they live in."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Reasons for Not Attending Summits"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "unattendance_str = \"If_you_haven't_been_able_to_attend_a_previous_summit,_was_there_a_primary_reason_why_(if_multiple,_list_the_leading_reason)\"\n",
    "unattendance_data = survey_data.dropna(subset=[unattendance_str])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "reason_for_not_going = (\n",
    "    p9.ggplot(unattendance_data, p9.aes(x=unattendance_str))\n",
    "    + p9.geom_bar()\n",
    "    + p9.theme(axis_text_x=p9.element_text(angle=45, ha=\"right\"))\n",
    "    + p9.labs(\n",
    "        title=\"Reasons for not attending summits\",\n",
    "        y=\"Number of Contributors\",\n",
    "        x=\"Reason\",\n",
    "    )\n",
    ")\n",
    "reason_for_not_going"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The largest reason for not attending the summits is that contributors feel they do not have enough funding to attend."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "unattendance_contrib = (\n",
    "    unattendance_data.groupby([\"Contributing_Length\", unattendance_str])\n",
    "    .count()[\"Respondent_ID\"]\n",
    "    .reset_index()\n",
    "    .merge(\n",
    "        unattendance_data.groupby([\"Contributing_Length\"])\n",
    "        .count()[\"Respondent_ID\"]\n",
    "        .reset_index(),\n",
    "        on=\"Contributing_Length\",\n",
    "    )\n",
    ")\n",
    "unattendance_contrib = unattendance_contrib.assign(\n",
    "    percent=unattendance_contrib.Respondent_ID_x / unattendance_contrib.Respondent_ID_y\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    p9.ggplot(unattendance_contrib,\n",
    "           p9.aes(x=unattendance_str,y='percent',fill='Contributing_Length')) +\n",
    "    p9.geom_bar(stat='identity',position='dodge') +\n",
    "    p9.theme(axis_text_x = p9.element_text(angle=45,ha='right')) + \n",
    "    p9.labs(title=\"Reasons for not attending summits\",\n",
    "            y = \"Proportion of Contributors\",\n",
    "            x= 'Reason',\n",
    "            fill=\"Contributing Length\") \n",
    ")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "When we look at the reasons for not attending the summits dependent the length of time a contributor has been involved with the project, we see that in addition to lacking funding, the longer tenured contributors tend to help at other events co-located with KubeCon even during the summits."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "unattendance_level = unattendance_data.groupby(['Level_of_Contributor',unattendance_str]).count()['Respondent_ID'].reset_index().merge(unattendance_data.groupby(['Level_of_Contributor']).count()['Respondent_ID'].reset_index(), on = 'Level_of_Contributor')\n",
    "unattendance_level = unattendance_level.assign(percent = unattendance_level.Respondent_ID_x/unattendance_level.Respondent_ID_y)\n",
    "\n",
    "(\n",
    "    p9.ggplot(unattendance_level,\n",
    "           p9.aes(x=unattendance_str,y='percent',fill='Level_of_Contributor')) +\n",
    "    p9.geom_bar(stat='identity',position=p9.position_dodge(preserve='single')) +\n",
    "    p9.theme(axis_text_x = p9.element_text(angle=45,ha='right')) + \n",
    "    p9.labs(title=\"Reasons for not attending summits\",\n",
    "            y = \"Number of Contributors\",\n",
    "            x= 'Reason',\n",
    "            fill= 'Level of Contributor') \n",
    ")\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As with above, the higher up the  ladder one is, the more likely the are to be helping out at another event. Interestingly, while approvers are higher on the ladder than reviewers, they are less likely to be attending KubeCon, as well as the summits."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "unattendance_support = (\n",
    "    unattendance_data.groupby([\"Upstream_supported_at_employer\", unattendance_str])\n",
    "    .count()[\"Respondent_ID\"]\n",
    "    .reset_index()\n",
    "    .merge(\n",
    "        unattendance_data.groupby([\"Upstream_supported_at_employer\"])\n",
    "        .count()[\"Respondent_ID\"]\n",
    "        .reset_index(),\n",
    "        on=\"Upstream_supported_at_employer\",\n",
    "    )\n",
    ")\n",
    "unattendance_support = unattendance_support.assign(\n",
    "    percent=unattendance_support.Respondent_ID_x / unattendance_support.Respondent_ID_y\n",
    ")\n",
    "\n",
    "(\n",
    "    p9.ggplot(\n",
    "        unattendance_support,\n",
    "        p9.aes(x=unattendance_str, y=\"percent\", fill=\"Upstream_supported_at_employer\"),\n",
    "    )\n",
    "    + p9.geom_bar(stat=\"identity\", position=p9.position_dodge(preserve=\"single\"))\n",
    "    + p9.theme(axis_text_x=p9.element_text(angle=45, ha=\"right\"))\n",
    "    + p9.labs(\n",
    "        title=\"Reasons for not attending summits\",\n",
    "        y=\"Number of Contributors\",\n",
    "        x=\"Reason\",\n",
    "        fill='Employer Support'\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Unsurprisingly, funding is a greater barrier to attendance to those who only work on Kubernetes on their own time, but is still a concern for about a third of those with some support from their employer."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Agreement with Statements"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "agree_ratings = [\"Strongly Disgree\", \"Disagree\", \"Neutral\", \"Agree\", \"Strongly Agree\"]\n",
    "(\n",
    "    make_likert_chart(survey_data, \"Agree:\", agree_ratings, max_is_high=True)\n",
    "    + p9.labs(x=\"Statement\", y=\"Number of Responses\", fill=\"Rating\", color=\"Rating\")\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Overall, the plot above displays the proportions one would hope to see. Many contributors are confident in their ability to understand continuous integration, and the related error messages enough to debug their code, while not feeling overburdened by test failures or notifications."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "(\n",
    "    make_likert_chart(\n",
    "        survey_data[survey_data[\"Blocker:_Debugging_test_failures\"] > 3],\n",
    "        \"Agree:\",\n",
    "        agree_ratings,\n",
    "        max_is_high=True,\n",
    "    )\n",
    "    + p9.labs(x=\"Statement\", y=\"Number of Responses\", fill=\"Rating\", color=\"Rating\")\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For those contributors who reported that debugging test failures is often or frequently a blocker, we see that the numbers are lower for those who understand CI and it's error messages in a broken PR. This is suggesting that if these areas were improved, less contributors would find debugging test failures to be a major blocker. On the other hand, it may suggest that there is no need to improve these tools, just more of an effort to educate about them. This is an area that could be investigated in future surveys, to best determine how to make debugging less of a blocker."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "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.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
