image_output_1.png
from plotly.offline import init_notebook_mode, iplot

from plotly.offline import init_notebook_mode, iplot

import pandas as pd

import plotly.graph_objs as go

import plotly.graph_objs as go

data = pd.read_csv('/kaggle/input/kaggle-survey-2020/kaggle_survey_2020_responses.csv')
df = data.iloc[1:, :]

init_notebook_mode(connected=True)
col = 'Q1'
v1 = df[col].value_counts().reset_index()
v1 = v1.rename(columns={col: 'count', 'index': col})
v1 = v1.sort_values(col)
trace1 = go.Bar(x=v1[col], y=v1['count'], marker=dict())
layout = {'title': 'Age Distribution', 'xaxis': {'title': 'Age Group'}, 'yaxis': {'title': 'Count'}}
fig = go.Figure(data=[trace1], layout=layout)

import plotly
import plotly.graph_objs as go
from plotly.offline import init_notebook_mode, iplot
init_notebook_mode(connected=True)
col = 'Q2'
grouped = df[col].value_counts().reset_index()
grouped = grouped.rename(columns={col: 'count', 'index': col})
trace = go.Pie(labels=grouped[col], values=grouped['count'], pull=[0.05, 0])
layout = {'title': 'Gender Distribution'}
fig = go.Figure(data=[trace], layout=layout)
iplot(fig)