From 985f97772d14d0e257e2a95b1ce0e94335c73a96 Mon Sep 17 00:00:00 2001 From: Sandeep Date: Thu, 8 Aug 2024 00:18:04 +0530 Subject: [PATCH] Add India Olympics --- .../India_Olympics-checkpoint.ipynb | 6 + Pandas/Olympic/src/India_Olympics.ipynb | 501 ++++++++++++++++++ 2 files changed, 507 insertions(+) create mode 100644 Pandas/Olympic/src/.ipynb_checkpoints/India_Olympics-checkpoint.ipynb create mode 100644 Pandas/Olympic/src/India_Olympics.ipynb diff --git a/Pandas/Olympic/src/.ipynb_checkpoints/India_Olympics-checkpoint.ipynb b/Pandas/Olympic/src/.ipynb_checkpoints/India_Olympics-checkpoint.ipynb new file mode 100644 index 0000000..363fcab --- /dev/null +++ b/Pandas/Olympic/src/.ipynb_checkpoints/India_Olympics-checkpoint.ipynb @@ -0,0 +1,6 @@ +{ + "cells": [], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Pandas/Olympic/src/India_Olympics.ipynb b/Pandas/Olympic/src/India_Olympics.ipynb new file mode 100644 index 0000000..4ba9e46 --- /dev/null +++ b/Pandas/Olympic/src/India_Olympics.ipynb @@ -0,0 +1,501 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "id": "314f814d-19de-42d0-9296-5e4c9e02f7ff", + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "cdb3b88b-c654-4dc7-9a3d-82310ef727f5", + "metadata": {}, + "outputs": [], + "source": [ + "df = pd.read_csv(\"olympics_1896_2004.csv\", skiprows = 5)" + ] + }, + { + "cell_type": "markdown", + "id": "59bcffa6-e804-4cf7-b006-c4a12cebbae0", + "metadata": {}, + "source": [ + "### Country is India" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "fb28a6d1-7801-4035-b616-8c3a0959475c", + "metadata": {}, + "outputs": [], + "source": [ + "df_India = df[df['NOC']== 'IND']" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6eb1ce86-8663-4801-9f4a-6a70f2ce2277", + "metadata": {}, + "outputs": [], + "source": [ + "df_India.rename(columns={\"Athlete Name\": \"Athlete_Name\", \"Event Gender\": \"Event_Gender\"}, inplace=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "29faa1c0-c7f5-40ce-96cd-5f3c0bd2223d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
YearCitySportDisciplineAthlete_NameNOCGenderEventEvent_GenderMedalPosition
1791900ParisAthleticsAthleticsPRITCHARD, NormanINDMen200mMSilver2
1881900ParisAthleticsAthleticsPRITCHARD, NormanINDMen200m hurdlesMSilver2
54721928AmsterdamHockeyHockeyALLEN, Richard JamesINDMenhockeyMGold1
54731928AmsterdamHockeyHockeyCHAND, DyanINDMenhockeyMGold1
\n", + "
" + ], + "text/plain": [ + " Year City Sport Discipline Athlete_Name NOC Gender \\\n", + "179 1900 Paris Athletics Athletics PRITCHARD, Norman IND Men \n", + "188 1900 Paris Athletics Athletics PRITCHARD, Norman IND Men \n", + "5472 1928 Amsterdam Hockey Hockey ALLEN, Richard James IND Men \n", + "5473 1928 Amsterdam Hockey Hockey CHAND, Dyan IND Men \n", + "\n", + " Event Event_Gender Medal Position \n", + "179 200m M Silver 2 \n", + "188 200m hurdles M Silver 2 \n", + "5472 hockey M Gold 1 \n", + "5473 hockey M Gold 1 " + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_India.head(4)" + ] + }, + { + "cell_type": "markdown", + "id": "143f9908-6a67-44d4-bd99-3786dbcded2c", + "metadata": {}, + "source": [ + "##### How many GOLD🥇 , Silver🥈, Bronze🥉 India won in respective years ?" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "id": "d6c21911-f56c-4c3a-908d-cd944db0e55b", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "np.int64(127)" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_India[df_India[\"Medal\"]==\"Gold\"][\"Year\"].value_counts().sum()" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "id": "95e61df3-d291-42a9-b314-4d5aa44c2527", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Year\n", + "1948 20\n", + "1956 17\n", + "1980 16\n", + "1964 15\n", + "1952 14\n", + "Name: count, dtype: int64" + ] + }, + "execution_count": 45, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_India[(df_India[\"Medal\"]==\"Gold\") & (df_India[\"Year\"] > 1947)][\"Year\"].value_counts()" + ] + }, + { + "cell_type": "markdown", + "id": "929dc9e6-2e46-40a4-a833-eafb99820485", + "metadata": {}, + "source": [ + "##### How many Discipline and sport are there for India ?" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "id": "5b527d17-6f92-493f-bc7a-458bc84f04a4", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "No of Games : 6\n", + "No of Discipline : 6\n", + "No of Event : 7\n" + ] + } + ], + "source": [ + "print(f\"No of Games : {df_India['Sport'].value_counts().count()}\")\n", + "print(f\"No of Discipline : {df_India['Discipline'].value_counts().count()}\")\n", + "print(f\"No of Event : {df_India['Event'].value_counts().count()}\")" + ] + }, + { + "cell_type": "markdown", + "id": "3c304f56-72e6-4b16-b190-f313f9e80906", + "metadata": {}, + "source": [ + "##### GOLD🥇 in different sports" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "id": "c4a02ae7-d8a5-42ba-851d-f2a3ad75913a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "np.int64(1)" + ] + }, + "execution_count": 50, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_India[df_India[\"Medal\"] == \"Gold\"]['Sport'].value_counts().count()" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "id": "6325a917-5148-4d72-b534-6f08d8a4e200", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "np.int64(3)" + ] + }, + "execution_count": 51, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_India[df_India[\"Medal\"] == \"Silver\"]['Sport'].value_counts().count()" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "id": "697e9d00-fa69-419b-b807-9dd132fc399b", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "np.int64(4)" + ] + }, + "execution_count": 52, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_India[df_India[\"Medal\"] == \"Bronze\"]['Sport'].value_counts().count()" + ] + }, + { + "cell_type": "markdown", + "id": "460b1183-6e18-4abd-bdc5-017303645a12", + "metadata": {}, + "source": [ + "##### How many GOLD🥇 won by males and females ?" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "id": "df62bf2b-d5cb-416d-b15d-afb3bd56532b", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Gender\n", + "Men 127\n", + "Name: count, dtype: int64" + ] + }, + "execution_count": 35, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_India[df_India[\"Medal\"] == \"Gold\"][\"Gender\"].value_counts()" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "id": "8c4ca4a8-58e0-44ee-bee9-a6aa874d0df9", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Gender\n", + "Men 174\n", + "Women 1\n", + "Name: count, dtype: int64" + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_India[\"Gender\"].value_counts()" + ] + }, + { + "cell_type": "markdown", + "id": "c3bc0602-c7bb-4c03-b118-8c42f3c6fbc8", + "metadata": {}, + "source": [ + "##### What is name of medal winner female ?" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "id": "35e8be8b-40fc-4ee4-a38e-0df10301a661", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
YearCitySportDisciplineAthlete_NameNOCGenderEventEvent_GenderMedalPosition
236892000SydneyWeightliftingWeightliftingMALLESWARI, KarnamINDWomen69kgWBronze3
\n", + "
" + ], + "text/plain": [ + " Year City Sport Discipline Athlete_Name NOC \\\n", + "23689 2000 Sydney Weightlifting Weightlifting MALLESWARI, Karnam IND \n", + "\n", + " Gender Event Event_Gender Medal Position \n", + "23689 Women 69kg W Bronze 3 " + ] + }, + "execution_count": 38, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_India[df_India[\"Gender\"] == \"Women\"]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5dabdf44-d6c4-4168-ba05-f650a601aa32", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.12.4" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}