diff --git a/anyway/parsers/schools_2024.ipynb b/anyway/parsers/schools_2024.ipynb index bc5b3806..315b9031 100644 --- a/anyway/parsers/schools_2024.ipynb +++ b/anyway/parsers/schools_2024.ipynb @@ -67,6 +67,25 @@ "MAIN_OUTPUT_DIR = \"/Users/atalya/Documents/anyway_main/repos/anyway/static/data/schools\"" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### create results dir" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "schools_results_directory = 'schools_results'\n", + "\n", + "if not os.path.exists(schools_results_directory):\n", + " os.mkdir(schools_results_directory)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -90,6 +109,33 @@ "light_weight = light/total" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def calc_heuristic_score(x):\n", + " h_score = x[\"killed_count\"] * 8 + \\\n", + " x[\"severe_injured_count\"] * 5 + \\\n", + " x[\"light_injured_count\"] * 1\n", + " return h_score" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def calc_prat_score(x):\n", + " prat_score = (x[\"killed_count\"] + x[\"severe_injured_count\"] + x[\"light_injured_count\"]) * \\\n", + " (x[\"killed_count\"] * killed_weight + \\\n", + " x[\"severe_injured_count\"] * severe_weight + \\\n", + " x[\"light_injured_count\"] * light_weight)\n", + " return prat_score\n" + ] + }, { "cell_type": "code", "execution_count": null, @@ -150,7 +196,7 @@ "metadata": {}, "outputs": [], "source": [ - "df['inv_unique_id'] = df['provider_and_id'].astype(str) + '_' + df['involve_id'].astype(str) + '_' + df['accident_year'].astype(str)\n" + "df['inv_unique_id'] = df['provider_and_id'].astype(str) + '_' + df['involve_id'].astype(str) + '_' + df['accident_year'].astype(str).copy()\n" ] }, { @@ -159,7 +205,7 @@ "metadata": {}, "outputs": [], "source": [ - "df['acc_unique_id'] = df['provider_and_id'].astype(str) + '_' + df['accident_year'].astype(str)\n" + "df['acc_unique_id'] = df['provider_and_id'].astype(str) + '_' + df['accident_year'].astype(str).copy()\n" ] }, { @@ -168,7 +214,7 @@ "metadata": {}, "outputs": [], "source": [ - "df['vehicle_or_pedestrian'] = df.apply(lambda x: x['involve_vehicle_type_hebrew'] if x['injured_type_hebrew'] != 'הולך רגל' else x['injured_type_hebrew'], axis=1)\n" + "df['vehicle_or_pedestrian'] = df.apply(lambda x: x['involve_vehicle_type_hebrew'] if x['injured_type_hebrew'] != 'הולך רגל' else x['injured_type_hebrew'], axis=1).copy()\n" ] }, { @@ -255,7 +301,112 @@ "metadata": {}, "outputs": [], "source": [ - "df['accident_month_hebrew'] = df['accident_month'].apply(lambda m: months_dict.get(m))" + "df['accident_month_hebrew'] = df['accident_month'].apply(lambda m: months_dict.get(m)).copy()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "df.loc[df.accident_yishuv_name == 'לא רשום', 'accident_yishuv_name'] = np.nan" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Add accident yishuv for yishuvs count" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "school_yishuvs = df.school_yishuv_name.unique()\n", + "accident_yishuvs = df.accident_yishuv_name.unique()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "df['yishuv_name_for_yishuves_count'] = df['school_yishuv_name'].copy()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "df['accident_yishuv_is_in_schools_yishuv'] = df['accident_yishuv_name'].apply(lambda x: x in school_yishuvs).copy()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "df_more_than_one_yishuv = df.groupby('inv_unique_id')['yishuv_name_for_yishuves_count'].nunique()\n", + "df_more_than_one_yishuv = df_more_than_one_yishuv[df_more_than_one_yishuv > 1 ]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "majority_school_yishuv = (df.groupby('inv_unique_id')['school_yishuv_name'].agg(lambda x: x.value_counts().index[0])).to_dict()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "inv_unique_id_more_than_one_yishuv = df_more_than_one_yishuv.index.values" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def get_yishuv_name_for_yishuves_count(s):\n", + " if s['accident_yishuv_is_in_schools_yishuv'] == True:\n", + " return s['accident_yishuv_name']\n", + " return majority_school_yishuv[s['inv_unique_id']]\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "df.loc[df.inv_unique_id.isin(inv_unique_id_more_than_one_yishuv), 'yishuv_name_for_yishuves_count'] = \\\n", + "df.loc[df.inv_unique_id.isin(inv_unique_id_more_than_one_yishuv)].apply(lambda x: get_yishuv_name_for_yishuves_count(x), axis=1)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "df_more_than_one_yishuv_2 = df.groupby('inv_unique_id')['yishuv_name_for_yishuves_count'].nunique()\n", + "df_more_than_one_yishuv_2 = df_more_than_one_yishuv_2[df_more_than_one_yishuv_2 > 1 ]\n" ] }, { @@ -284,6 +435,230 @@ "df_last_5_years = df.loc[(df.accident_timestamp.dt.date >= first_5_years_start)].copy()" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### CALC PER YISHUV FIRST 5 YEARS" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "curr_df = df_first_5_years.copy()\n", + "\n", + "df_total_injured = (\n", + " curr_df.groupby(\n", + " [\n", + " \"yishuv_name_for_yishuves_count\",\n", + " \"injury_severity\"\n", + " ]\n", + " )[\"inv_unique_id\"]\n", + " .nunique()\n", + " .reset_index(name=\"injured_count\")\n", + " .loc[\n", + " :,\n", + " [\n", + " \"yishuv_name_for_yishuves_count\",\n", + " \"injury_severity\",\n", + " \"injured_count\",\n", + " ],\n", + " ]\n", + ")\n", + "df_total_injured = df_total_injured.set_index(\n", + " [\n", + " \"yishuv_name_for_yishuves_count\",\n", + " \"injury_severity\",\n", + "\n", + " ]\n", + ").unstack(-1)\n", + "df_total_injured.fillna({\"injured_count\": 0, \"total_injured_count\": 0}, inplace=True)\n", + "\n", + "\n", + "df_total_injured.loc[:, (slice(\"injured_count\"), slice(None))] = df_total_injured.loc[\n", + " :, (slice(\"injured_count\"), slice(None))\n", + "].apply(lambda x: x.apply(int))\n", + "\n", + "df_total_injured[\"total_injured_count\"] = (\n", + " df_total_injured.loc[:, [\"injured_count\"]].sum(axis=1)\n", + ").apply(int)\n", + "\n", + "df_total_accidents_yishuvs = (\n", + " curr_df.groupby(\n", + " [\n", + " \"yishuv_name_for_yishuves_count\",\n", + " ]\n", + " )[\"acc_unique_id\"]\n", + " .nunique()\n", + " .reset_index(name=\"accidents_count\")\n", + " .loc[\n", + " :,\n", + " [\n", + " \"yishuv_name_for_yishuves_count\",\n", + " \"accidents_count\"\n", + " ],\n", + " ]\n", + ")\n", + "\n", + "df_total_accidents_yishuvs = df_total_accidents_yishuvs.set_index(\n", + "[\n", + " \"yishuv_name_for_yishuves_count\"])\n", + "\n", + "df_total_injured_for_merge = df_total_injured.copy()\n", + "df_total_injured_for_merge.columns = ['killed_count', 'severe_injured_count', 'light_injured_count', 'total_injured_count']\n", + "df_total_yishuvs_first_5_years = pd.merge(df_total_injured_for_merge,\n", + " df_total_accidents_yishuvs,\n", + " left_index=True,\n", + " right_index=True,\n", + " how='left')\n", + "\n", + "df_total_yishuvs_first_5_years.columns = ['killed_count', 'severe_injured_count', 'light_injured_count', 'total_injured_count', 'accidents_count']\n", + "\n", + "df_total_yishuvs_first_5_years['prat_score'] = df_total_yishuvs_first_5_years.apply(lambda x: calc_prat_score(x), axis=1)\n", + "\n", + "df_total_yishuvs_first_5_years['h_score'] = df_total_yishuvs_first_5_years.apply(lambda x: calc_heuristic_score(x), axis=1)\n", + "\n", + "df_total_yishuvs_first_5_years = df_total_yishuvs_first_5_years.sort_values('prat_score', ascending=False)\n", + "\n", + "\n", + "df_total_yishuvs_first_5_years.columns = [c + '_14_19' for c in df_total_yishuvs_first_5_years.columns]\n", + "\n", + "\n", + "df_total_yishuvs_first_5_years.to_csv(os.path.join(schools_results_directory,'scores_per_yishuv_first_5_years.csv'))\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### CALC PER YISHUV LAST 5 YEARS" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "curr_df = df_last_5_years.copy()\n", + "\n", + "df_total_injured = (\n", + " curr_df.groupby(\n", + " [\n", + " \"yishuv_name_for_yishuves_count\",\n", + " \"injury_severity\"\n", + " ]\n", + " )[\"inv_unique_id\"]\n", + " .nunique()\n", + " .reset_index(name=\"injured_count\")\n", + " .loc[\n", + " :,\n", + " [\n", + " \"yishuv_name_for_yishuves_count\",\n", + " \"injury_severity\",\n", + " \"injured_count\",\n", + " ],\n", + " ]\n", + ")\n", + "df_total_injured = df_total_injured.set_index(\n", + " [\n", + " \"yishuv_name_for_yishuves_count\",\n", + " \"injury_severity\",\n", + "\n", + " ]\n", + ").unstack(-1)\n", + "df_total_injured.fillna({\"injured_count\": 0, \"total_injured_count\": 0}, inplace=True)\n", + "\n", + "\n", + "df_total_injured.loc[:, (slice(\"injured_count\"), slice(None))] = df_total_injured.loc[\n", + " :, (slice(\"injured_count\"), slice(None))\n", + "].apply(lambda x: x.apply(int))\n", + "\n", + "df_total_injured[\"total_injured_count\"] = (\n", + " df_total_injured.loc[:, [\"injured_count\"]].sum(axis=1)\n", + ").apply(int)\n", + "\n", + "df_total_accidents_yishuvs = (\n", + " curr_df.groupby(\n", + " [\n", + " \"yishuv_name_for_yishuves_count\",\n", + " ]\n", + " )[\"acc_unique_id\"]\n", + " .nunique()\n", + " .reset_index(name=\"accidents_count\")\n", + " .loc[\n", + " :,\n", + " [\n", + " \"yishuv_name_for_yishuves_count\",\n", + " \"accidents_count\"\n", + " ],\n", + " ]\n", + ")\n", + "\n", + "df_total_accidents_yishuvs = df_total_accidents_yishuvs.set_index(\n", + "[\n", + " \"yishuv_name_for_yishuves_count\"])\n", + "\n", + "\n", + "df_total_injured_for_merge = df_total_injured.copy()\n", + "df_total_injured_for_merge.columns = ['killed_count', 'severe_injured_count', 'light_injured_count', 'total_injured_count']\n", + "df_total_yishuvs_last_5_years = pd.merge(df_total_injured_for_merge,\n", + " df_total_accidents_yishuvs,\n", + " left_index=True,\n", + " right_index=True,\n", + " how='left')\n", + "\n", + "df_total_yishuvs_last_5_years.columns = ['killed_count', 'severe_injured_count', 'light_injured_count', 'total_injured_count', 'accidents_count']\n", + "\n", + "df_total_yishuvs_last_5_years['prat_score'] = df_total_yishuvs_last_5_years.apply(lambda x: calc_prat_score(x), axis=1)\n", + "\n", + "df_total_yishuvs_last_5_years['h_score'] = df_total_yishuvs_last_5_years.apply(lambda x: calc_heuristic_score(x), axis=1)\n", + "\n", + "df_total_yishuvs_last_5_years = df_total_yishuvs_last_5_years.sort_values('prat_score', ascending=False)\n", + "\n", + "df_total_yishuvs_last_5_years.columns = [c + '_19_24' for c in df_total_yishuvs_last_5_years.columns]\n", + "\n", + "df_total_yishuvs_last_5_years.to_csv(os.path.join(schools_results_directory,'scores_per_yishuv_last_5_years.csv'))\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### CALC DIFF" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "df_all_yishuvs_per_5_years_group = pd.concat([df_total_yishuvs_first_5_years, df_total_yishuvs_last_5_years], axis=1)\n", + "\n", + "df_all_yishuvs_per_5_years_group['%change_prat'] = 100 * (df_all_yishuvs_per_5_years_group['prat_score_19_24'] - df_all_yishuvs_per_5_years_group['prat_score_14_19']) / df_all_yishuvs_per_5_years_group['prat_score_14_19']\n", + "\n", + "\n", + "df_total_yishuvs_first_5_years.to_csv(os.path.join(schools_results_directory,'scores_per_yishuv_first_5_years.csv'))\n", + "\n", + "\n", + "df_total_yishuvs_last_5_years.to_csv(os.path.join(schools_results_directory,'scores_per_yishuv_last_5_years.csv'))\n", + "\n", + "\n", + "df_all_yishuvs_per_5_years_group.to_csv(os.path.join(schools_results_directory,'scores_per_yishuv_5_years_periods.csv'))\n", + "\n", + "\n", + "df_all_yishuvs_per_5_years_group_top_20_prat_19_24 = df_all_yishuvs_per_5_years_group.sort_values('prat_score_19_24', ascending=False)[0:20].sort_values('%change_prat', ascending=False)\n", + "\n", + "\n", + "df_all_yishuvs_per_5_years_group_top_20_prat_19_24.to_csv(os.path.join(schools_results_directory,'scores_per_yishuv_5_years_periods_top_20_prat_19_24_sorted_diff_prat.csv'))\n" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -306,7 +681,7 @@ "metadata": {}, "outputs": [], "source": [ - "assert(round(((df['accident_timestamp'].max() - df['accident_timestamp'].min()).days / 365),0) == total_number_of_years)\n" + "assert(round(((df['accident_timestamp'].max() - df['accident_timestamp'].min()).days / 365),0) == TOTAL_YEARS)\n" ] }, { @@ -367,15 +742,8 @@ "metadata": {}, "outputs": [], "source": [ - "schools_results_directory = 'schools_results'" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ + "schools_results_directory = 'schools_results'\n", + "\n", "if not os.path.exists(schools_results_directory):\n", " os.mkdir(schools_results_directory)" ] @@ -1097,261 +1465,6 @@ "top_20_yishuvs = top_20_yishuvs.to_frame().reset_index()" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### calc per yisuv and years" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "curr_df = df_first_5_years.copy()\n", - "\n", - "df_total_injured = (\n", - " curr_df.groupby(\n", - " [\n", - " \"school_yishuv_name\",\n", - " \"injury_severity\"\n", - " ]\n", - " )[\"inv_unique_id\"]\n", - " .nunique()\n", - " .reset_index(name=\"injured_count\")\n", - " .loc[\n", - " :,\n", - " [\n", - " \"school_yishuv_name\",\n", - " \"injury_severity\",\n", - " \"injured_count\",\n", - " ],\n", - " ]\n", - ")\n", - "df_total_injured = df_total_injured.set_index(\n", - " [\n", - " \"school_yishuv_name\",\n", - " \"injury_severity\",\n", - "\n", - " ]\n", - ").unstack(-1)\n", - "df_total_injured.fillna({\"injured_count\": 0, \"total_injured_count\": 0}, inplace=True)\n", - "\n", - "\n", - "df_total_injured.loc[:, (slice(\"injured_count\"), slice(None))] = df_total_injured.loc[\n", - " :, (slice(\"injured_count\"), slice(None))\n", - "].apply(lambda x: x.apply(int))\n", - "\n", - "df_total_injured[\"total_injured_count\"] = (\n", - " df_total_injured.loc[:, [\"injured_count\"]].sum(axis=1)\n", - ").apply(int)\n", - "\n", - "df_total_accidents_yishuvs = (\n", - " curr_df.groupby(\n", - " [\n", - " \"school_yishuv_name\",\n", - " ]\n", - " )[\"acc_unique_id\"]\n", - " .nunique()\n", - " .reset_index(name=\"accidents_count\")\n", - " .loc[\n", - " :,\n", - " [\n", - " \"school_yishuv_name\",\n", - " \"accidents_count\"\n", - " ],\n", - " ]\n", - ")\n", - "\n", - "df_total_accidents_yishuvs = df_total_accidents_yishuvs.set_index(\n", - "[\n", - " \"school_yishuv_name\"])\n", - "\n", - "df_total_injured_for_merge = df_total_injured.copy()\n", - "df_total_injured_for_merge.columns = ['killed_count', 'severe_injured_count', 'light_injured_count', 'total_injured_count']\n", - "df_total_yishuvs_first_5_years = pd.merge(df_total_injured_for_merge,\n", - " df_total_accidents_yishuvs,\n", - " left_index=True,\n", - " right_index=True,\n", - " how='left')\n", - "\n", - "df_total_yishuvs_first_5_years.columns = ['killed_count', 'severe_injured_count', 'light_injured_count', 'total_injured_count', 'accidents_count']\n", - "\n", - "df_total_yishuvs_first_5_years['prat_score'] = df_total_yishuvs_first_5_years.apply(lambda x: calc_prat_score(x), axis=1)\n", - "\n", - "df_total_yishuvs_first_5_years['h_score'] = df_total_yishuvs_first_5_years.apply(lambda x: calc_heuristic_score(x), axis=1)\n", - "\n", - "df_total_yishuvs_first_5_years = df_total_yishuvs_first_5_years.sort_values('prat_score', ascending=False)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "curr_df = df_last_5_years.copy()\n", - "\n", - "df_total_injured = (\n", - " curr_df.groupby(\n", - " [\n", - " \"school_yishuv_name\",\n", - " \"injury_severity\"\n", - " ]\n", - " )[\"inv_unique_id\"]\n", - " .nunique()\n", - " .reset_index(name=\"injured_count\")\n", - " .loc[\n", - " :,\n", - " [\n", - " \"school_yishuv_name\",\n", - " \"injury_severity\",\n", - " \"injured_count\",\n", - " ],\n", - " ]\n", - ")\n", - "df_total_injured = df_total_injured.set_index(\n", - " [\n", - " \"school_yishuv_name\",\n", - " \"injury_severity\",\n", - "\n", - " ]\n", - ").unstack(-1)\n", - "df_total_injured.fillna({\"injured_count\": 0, \"total_injured_count\": 0}, inplace=True)\n", - "\n", - "\n", - "df_total_injured.loc[:, (slice(\"injured_count\"), slice(None))] = df_total_injured.loc[\n", - " :, (slice(\"injured_count\"), slice(None))\n", - "].apply(lambda x: x.apply(int))\n", - "\n", - "df_total_injured[\"total_injured_count\"] = (\n", - " df_total_injured.loc[:, [\"injured_count\"]].sum(axis=1)\n", - ").apply(int)\n", - "\n", - "df_total_accidents_yishuvs = (\n", - " curr_df.groupby(\n", - " [\n", - " \"school_yishuv_name\",\n", - " ]\n", - " )[\"acc_unique_id\"]\n", - " .nunique()\n", - " .reset_index(name=\"accidents_count\")\n", - " .loc[\n", - " :,\n", - " [\n", - " \"school_yishuv_name\",\n", - " \"accidents_count\"\n", - " ],\n", - " ]\n", - ")\n", - "\n", - "df_total_accidents_yishuvs = df_total_accidents_yishuvs.set_index(\n", - "[\n", - " \"school_yishuv_name\"])\n", - "\n", - "\n", - "df_total_injured_for_merge = df_total_injured.copy()\n", - "df_total_injured_for_merge.columns = ['killed_count', 'severe_injured_count', 'light_injured_count', 'total_injured_count']\n", - "df_total_yishuvs_last_5_years = pd.merge(df_total_injured_for_merge,\n", - " df_total_accidents_yishuvs,\n", - " left_index=True,\n", - " right_index=True,\n", - " how='left')\n", - "\n", - "df_total_yishuvs_last_5_years.columns = ['killed_count', 'severe_injured_count', 'light_injured_count', 'total_injured_count', 'accidents_count']\n", - "\n", - "df_total_yishuvs_last_5_years['prat_score'] = df_total_yishuvs_last_5_years.apply(lambda x: calc_prat_score(x), axis=1)\n", - "\n", - "df_total_yishuvs_last_5_years['h_score'] = df_total_yishuvs_last_5_years.apply(lambda x: calc_heuristic_score(x), axis=1)\n", - "\n", - "df_total_yishuvs_last_5_years = df_total_yishuvs_last_5_years.sort_values('prat_score', ascending=False)\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "df_total_yishuvs_first_5_years.columns = [c + '_14_19' for c in df_total_yishuvs_first_5_years.columns]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "df_total_yishuvs_last_5_years.columns = [c + '_19_24' for c in df_total_yishuvs_last_5_years.columns]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "df_all_yishuvs_per_5_years_group = pd.concat([df_total_yishuvs_first_5_years, df_total_yishuvs_last_5_years], axis=1)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "df_all_yishuvs_per_5_years_group['%change_prat'] = 100 * (df_all_yishuvs_per_5_years_group['prat_score_19_24'] - df_all_yishuvs_per_5_years_group['prat_score_14_19']) / df_all_yishuvs_per_5_years_group['prat_score_14_19']\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "df_total_yishuvs_first_5_years.to_csv(os.path.join(schools_results_directory,'scores_per_yishuv_first_5_years.csv'))\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "df_total_yishuvs_last_5_years.to_csv(os.path.join(schools_results_directory,'scores_per_yishuv_last_5_years.csv'))\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "df_all_yishuvs_per_5_years_group.to_csv(os.path.join(schools_results_directory,'scores_per_yishuv_5_years_periods.csv'))\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "df_all_yishuvs_per_5_years_group_top_20_prat_19_24 = df_all_yishuvs_per_5_years_group.sort_values('prat_score_19_24', ascending=False)[0:20].sort_values('%change_prat', ascending=False)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "df_all_yishuvs_per_5_years_group_top_20_prat_19_24.to_csv(os.path.join(schools_results_directory,'scores_per_yishuv_5_years_periods_top_20_prat_19_24_sorted_diff_prat.csv'))\n" - ] - }, { "cell_type": "markdown", "metadata": {},