text_plain_output_1.png
import matplotlib.pyplot as plt

import pandas as pd

df = pd.read_csv('/kaggle/input/ufc-fights-2010-2020-with-betting-odds/data.csv')

df = df.dropna()

year_labels = []
for z in range(2010, 2021):
    year_labels.append(z)
fight_counts = []
for z in year_labels:
    fight_counts.append(len(df[df['date'].dt.year == z]))

female_fight_counts = []
for z in year_labels:
    female_fight_counts.append(len(df[(df['date'].dt.year == z) & (df['gender'] == 'FEMALE')]))

df_no_even = df[df['underdog'] != 'Even']
df_no_even = df_no_even[df_no_even['Winner'] != 'Draw']

number_of_fights = len(df_no_even)
number_of_upsets = len(df_no_even[df_no_even['Winner'] == df_no_even['underdog']])
number_of_favorites = len(df_no_even[df_no_even['Winner'] != df_no_even['underdog']])
upset_percent = number_of_upsets / number_of_fights * 100
favorite_percent = number_of_favorites / number_of_fights * 100
labels = ('Favorites', 'Underdogs')
sizes = [favorite_percent, upset_percent]
fig1, ax1 = plt.subplots(figsize=(9, 9))
ax1.pie(sizes, labels=labels, autopct='%1.1f%%', textprops={'fontsize': 14})