<jupyter_start><jupyter_text>Author : <NAME> - TIP Data Science October-2021 Task 3 : Nobel Prize Distribution Dataset : https://drive.google.com/file/d/1B_DQcYgvnvVQd7mM6BKzg523yzge44oZ/view Importing required Libraries<jupyter_code>import pandas as ps
import numpy as np # linear algebra
import matplotlib.pyplot as plt
import seaborn as sn
from pandas_profiling import ProfileReport
import warnings
warnings.filterwarnings('ignore')<jupyter_output><empty_output><jupyter_text>Importing dataset<jupyter_code># importing the dataset(csv file)

df = ps.read_csv('nobel_prize_by_winner.csv')
df
df.head(10)
# Primary checks
df.describe() #Less numeric description as string leads as datatypes
# Data types
df.dtypes
df.shape
df.columns
# Getting information about the Data
df.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
RangeIndex: 972 entries, 0 to 971
Data columns (total 20 columns):
 #   Column             Non-Null Count  Dtype  
---  ------             --------------  -----  
 0   id                 972 non-null    int64  
 1   firstname          966 non-null    object 
 2   surname            936 non-null    object 
 3   born               946 non-null    object 
 4   died               946 non-null    object 
 5   bornCountry        940 non-null    object 
 6   bornCountryCode    940 non-null    object 
 7   bornCity           938 non-null    object 
 8   diedCountry        601 non-null    object 
 9   diedCountryCode    600 non-null    object 
 10  diedCity           595 non-null    object 
 11  gender             972 non-null    object 
 12  year               966 non-null    float64
 13  category           966 non-null    object 
 14  overallMotivation  16 non-null     object 
 15  share              966 non-null    float64
 16  motivation         878 non[...]<jupyter_text>Step 1 : Data cleanup and processing( Columns such as Motivation, City, diedCity have NaNs, raw text, special chars)<jupyter_code># Null values check
df.isnull().sum()
# dropping columns that are not needed for quants.

winners = df.drop(columns=['id','died','bornCity','bornCountry','diedCountry','diedCountryCode','diedCity','motivation','overallMotivation','name','city','country'],axis=1)
winners.head(10)
winners1 = winners.dropna(subset=['year','share','category'])
winners1.shape #head(10)
# Converting datatypes into relative ones.
dtype_converter = {'firstname': str,
                    'surname':str,
                    'share':int,
                    'year':int,
                    'gender':str }
winners1 = winners1.astype(dtype_converter)

# Let's do something about dates and convert to 'age'
print(winners1.dtypes)
# Seperating the winners who are alive.

alive = winners1.loc[df['died'] == "0000-00-00" ]

category_dummies = ps.get_dummies(alive['category'])
category_dummies

gender_dummies = ps.get_dummies(alive['gender'])
gender_dummies
alive2 = ps.concat([alive,category_dummies,gender_dummies],axis=1)
alive2.head(10)
# Time to plot graphs
# Category: peace


CountryVsCat = alive2.groupby('bornCountryCode')['peace'].sum()
plt.figure(figsize=(28,11))
sn.barplot(x=CountryVsCat.index,y=CountryVsCat.values,palette = "cividis")
# Category: chemistry


CountryVsCat = alive2.groupby('bornCountryCode')['chemistry'].sum()
plt.figure(figsize=(28,11))
sn.barplot(x=CountryVsCat.index,y=CountryVsCat.values,palette = "magma").set_title("Chemistry - Counts")
CountryVsCat = alive2.groupby('bornCountryCode')['literature'].sum()
plt.figure(figsize=(28,11))
sn.barplot(x=CountryVsCat.index,y=CountryVsCat.values,palette = "rainbow").set_title("literature - Counts")
CountryVsCat = alive2.groupby('bornCountryCode')['economics'].sum()
plt.figure(figsize=(28,11))
sn.barplot(x=CountryVsCat.index,y=CountryVsCat.values,palette = "rocket").set_title("economics - Counts")
CountryVsCat = alive2.groupby('bornCountryCode')['medicine'].sum()
plt.figure(figsize=(28,11))
sn.barplot(x=CountryVsCat.index,y=CountryVsCat.values,palette = "mako").set_title("medicine - Counts")
CountryVsCat = alive2.groupby('bornCountryCode')['physics'].sum()
plt.figure(figsize=(28,11))
sn.barplot(x=CountryVsCat.index,y=CountryVsCat.values,palette = "flare").set_title("physics - Counts")
male_count = alive2['male'].value_counts().values[0]
female_count = alive2['female'].value_counts().values[1]
total = male_count+female_count
fig , ax = plt.subplots()
plt.figure(figsize=(25,11))

labels = ['males','females']
values1 = [((male_count/total)*100),((female_count/total)*100)]


ax.pie(values1,labels=labels)
ax.set_title("Male Vs Female winner counts")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12957317073170732, 'fraction_numerical': 0.038109756097560975, 'mean_word_length': 4.041712403951702, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '119626', 'license': 'MIT', 'n_tokens_mistral': 1674, 'n_tokens_neox': 1492, 'n_words': 312, 'path': 'Task 3 - Nobel Prize Distribution/Task 3 - Nobel Prize Distribution.ipynb', 'repo_name': 'akashloka/TechEdu-TIP-Data-Science', 'size': '4610'}