text_html_output_1.png
import pandas as pd

import plotly.express as px

import plotly.graph_objs as go

import plotly.offline as py

data = pd.read_csv('/kaggle/input/kaggle-survey-2020/kaggle_survey_2020_responses.csv')
questions = data.iloc[0, :].T
data = data.iloc[1:, :]
data.rename({'Q1': 'AGE GROUP'}, axis=1, inplace=True)
data.rename({'Q2': 'GENDER'}, axis=1, inplace=True)
data.rename({'Q3': 'COUNTRY'}, axis=1, inplace=True)
data.rename({'Q4': 'EDUCATION'}, axis=1, inplace=True)
data.rename({'Q5': 'TITLE'}, axis=1, inplace=True)
data.rename({'Q6': 'CODING EXP'}, axis=1, inplace=True)
data.rename({'Q8': '1ST LANG'}, axis=1, inplace=True)
idata = data[data['COUNTRY'] == 'India']
imale = idata[idata['GENDER'] == 'Man']
ifemale = idata[idata['GENDER'] == 'Woman']

country_wise_distribution = data['COUNTRY'].value_counts()
fig = px.choropleth(country_wise_distribution.values, locations=country_wise_distribution.index, locationmode='country names', color=country_wise_distribution.values, labels={'color': 'Count', 'locations': 'Location'}, color_continuous_scale=px.colors.sequential.OrRd)
fig.update_layout(title='COUNTRYWISE DISTRIBUTION')

fig = px.histogram(data, y="COUNTRY", histnorm='percent')
fig.update_layout(xaxis={"ticksuffix":"%"})
fig.update_layout(xaxis_title="COUNT PERCENTAGE")
fig.update_traces(marker_color='rgb(255,128,128)', marker_line_color='rgb(255,128,128)',
                  marker_line_width=1.5, opacity=1)
fig.show()

counts = data['GENDER'].value_counts(sort=True)
labels = counts.index
values = counts.values
o_pie = go.Pie(labels=labels, values=values, name='Overall', hole=0.3, domain={'x': [0, 0.46]})
icounts = idata['GENDER'].value_counts(sort=True)
ilabels = icounts.index
ivalues = icounts.values
i_pie = go.Pie(labels=ilabels, values=ivalues, name='India', hole=0.3, domain={'x': [0.52, 1]})
layout = dict(title='GENDER DISTRIBUTION', font=dict(size=12), legend=dict(orientation='h'), annotations=[dict(x=0.17, y=0.5, text='Overall', showarrow=False, font=dict(size=20)), dict(x=0.8, y=0.5, text='India', showarrow=False, font=dict(size=20))])
fig = dict(data=[o_pie, i_pie], layout=layout)

labels = ['18-21', '22-24', '25-29', '30-34', '35-39', '40-44', '45-49', '50-54', '55-59', '60-69', '70+']
o_values = data['AGE GROUP'].value_counts(sort=True).values
o_pie = go.Pie(labels=labels, values=o_values, name='Overall', hole=0.3, domain={'x': [0, 0.46]})
i_values = idata['AGE GROUP'].value_counts(sort=True).values
i_pie = go.Pie(labels=labels, values=i_values, name='India', hole=0.3, domain={'x': [0.52, 1]})
layout = dict(title='AGE GROUPWISE DISTRIBUTION', font=dict(size=10), legend=dict(orientation='h'), annotations=[dict(x=0.17, y=0.5, text='Overall', showarrow=False, font=dict(size=20)), dict(x=0.8, y=0.5, text='India', showarrow=False, font=dict(size=20))])
fig = dict(data=[o_pie, i_pie], layout=layout)

counts = data['EDUCATION'].value_counts(sort=True)
labels = counts.index
values = counts.values
o_pie = go.Pie(labels=labels, values=values, name='Overall', hole=0.3, domain={'x': [0, 0.46]})
icounts = idata['EDUCATION'].value_counts(sort=True)
ilabels = icounts.index
ivalues = icounts.values
i_pie = go.Pie(labels=ilabels, values=ivalues, name='India', hole=0.3, domain={'x': [0.52, 1]})
layout = dict(title='HIGHER EDUCATION', font=dict(size=12), legend=dict(orientation='h'), annotations=[dict(x=0.17, y=0.5, text='Overall', showarrow=False, font=dict(size=20)), dict(x=0.8, y=0.5, text='India', showarrow=False, font=dict(size=20))])
fig = dict(data=[o_pie, i_pie], layout=layout)

fig = px.histogram(idata, y='EDUCATION', color='AGE GROUP')
fig.update_layout(title='AGE GROUPWISE HIGHER EDUCATION DISTRIBUTION - INDIA')
fig.show()