text_plain_output_1.png image_output_1.png
import matplotlib.patches as mpatches

import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
import matplotlib.patches as mpatches
sns.set_style(style='whitegrid')

data = pd.read_csv('/kaggle/input/kaggle-survey-2020/kaggle_survey_2020_responses.csv', low_memory=False)
data.columns = data.iloc[0]
data.drop(data.index[0], inplace=True)

questions = list(data.columns)
question_df = pd.DataFrame(data.columns, columns=['questions'])

age_groups = data[data.columns[1]].value_counts().sort_index()
mill = age_groups['22-24'] + age_groups['25-29']
mill_percentage = mill / age_groups.sum() * 100

gender = data[data.columns[2]].value_counts()
man = gender['Man']
woman = gender['Woman']
diff_p = (man - woman) / woman * 100

Male = data[data[questions[2]] == 'Man']
Female = data[data[questions[2]] == 'Woman']

fig, ax = plt.subplots()
m_age_groups = Male[Male.columns[1]].value_counts().sort_index()
sns.barplot(m_age_groups,m_age_groups.index,color="cyan")
f_age_groups = Female[Female.columns[1]].value_counts().sort_index()
sns.barplot(-1 * f_age_groups,f_age_groups.index,color="salmon")
ticks =  ax.get_xticks()
plt.tight_layout()
ax.set_xticklabels([int(abs(tick)) for tick in ticks])

red_patch = mpatches.Patch(color='salmon', label='Female')
black_patch = mpatches.Patch(color='cyan', label='Male')
plt.legend(handles=[red_patch, black_patch])

plt.show()

plt.rcParams['figure.figsize'] = (10, 10)
country = data[data.columns[3]].value_counts()
perce = country['India'] / country.sum() * 100

ITEM = data[data.columns[4]].value_counts()
perc = (ITEM.iloc[0] + ITEM.iloc[0]) / ITEM.sum() * 100
print(f'Masters and Bachelor graduates constitute {perc}% of the total demographic.')
sns.barplot(ITEM, ITEM.index)
plt.show()