text_html_output_1.png
from plotly.offline import init_notebook_mode, iplot, plot

import pandas as pd

import plotly.graph_objs as go

medal = pd.read_excel('../input/2021-olympics-in-tokyo/Medals.xlsx', index_col=0)
athlete = pd.read_excel('../input/2021-olympics-in-tokyo/Athletes.xlsx', index_col=0)
gender = pd.read_excel('../input/2021-olympics-in-tokyo/EntriesGender.xlsx', index_col=0)
team = pd.read_excel('../input/2021-olympics-in-tokyo/Teams.xlsx', index_col=0)
coach = pd.read_excel('../input/2021-olympics-in-tokyo/Coaches.xlsx', index_col=0)

gender['male_ratio'] = gender['Male'] / gender['Total']
gender['female_ratio'] = gender['Female'] / gender['Total']
gender['Discipline'] = gender.index

from plotly.offline import init_notebook_mode, iplot, plot
import plotly as py
init_notebook_mode(connected=True)
import plotly.graph_objs as go
fig = go.Figure()
fig.add_trace(go.Bar(y=gender.Discipline, x=gender.female_ratio, orientation='h', name='Females'))
fig.add_trace(go.Bar(y=gender.Discipline, x=gender.male_ratio, orientation='h', name='Males'))
template = dict(layout=go.Layout(title_font=dict(family='Rockwell', size=30)))
fig.update_layout(title='Distribution of disciplines based on gender', template=template, barmode='stack', autosize=False, width=680, height=900, margin=dict(l=150, r=100, b=30, t=100, pad=4))
fig.layout.xaxis.tickformat = ',.0%'

medal.rename(columns={'Team/NOC': 'NOC'}, inplace=True)
medalf = medal.sort_values(by='Rank by Total', ascending=True).head(10)
fig = go.Figure()
fig.add_trace(go.Bar(y=medalf.Gold, x=medalf.NOC, name='Gold'))
fig.add_trace(go.Bar(y=medalf.Silver, x=medalf.NOC, name='Silver'))
fig.add_trace(go.Bar(y=medalf.Bronze, x=medalf.NOC, name='Bronze'))
template = dict(layout=go.Layout(title_font=dict(family='Rockwell', size=30)))
fig.update_layout(title='Medal Distribution', template=template, barmode='stack', autosize=False, width=680, height=650, margin=dict(l=30, r=30, b=180, t=100, pad=4))
fig.layout.xaxis.tickformat = ',.0%'
fig.show()