from k2datascience import olympics

from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
%matplotlib inline

"""
Explanation: Exercises

Timothy Helton

<br>
<font color="red">
    NOTE:
    <br>
    This notebook uses code found in the
    <a href="https://github.com/TimothyHelton/k2datascience/blob/master/k2datascience/olympics.py">
    <strong>k2datascience.olympics</strong></a> module.
    To execute all the cells do one of the following items:
    <ul>
        <li>Install the k2datascience package to the active Python interpreter.</li>
        <li>Add k2datascience/k2datascience to the PYTHON_PATH system variable.</li>
        <li>Create a link to the olympics.py file in the same directory as this notebook.</li>
</font>

Imports
End of explanation
"""


oly = olympics.Medals()

print(f'{"#" * 30}\nAthletes Data\n\n')
print(f'Data Types:\n{oly.athletes.dtypes}\n\n')
print(f'Data Shape:\n{oly.athletes.shape}\n\n')
print(f'Missing Data:\n{oly.athletes.isnull().sum()}\n\n')
oly.athletes.head()
oly.athletes.tail()
oly.athletes.describe()

print(f'\n\n\n{"#" * 30}\nCountries Data\n\n')
print(f'Data Types:\n{oly.countries.dtypes}\n\n')
print(f'Data Shape:\n{oly.countries.shape}\n\n')
print(f'Missing Data:\n{oly.countries.isnull().sum()}\n\n')
oly.countries.head()
oly.countries.tail()
oly.countries.describe()

"""
Explanation: Data Prep
End of explanation
"""


oly.calc_age_means()

"""
Explanation: 1. What was the average age in male and female athletes?
End of explanation
"""


oly.common_full_birthday()

"""
Explanation: 2. What are the most common Dates of Birth?
To clarify - day, month, year
End of explanation
"""


oly.common_month_day_birthday()

"""
Explanation: 3. How about the most common birthdays?

Most Common Month
Modst Common Day
End of explanation
"""


(oly.country_medals
 .query('total > 100')
 .sort_values('total', ascending=False))

"""
Explanation: 4. What are the Countries with more than 100 medals?
End of explanation
"""


oly.country_medals_plot()

"""
Explanation: 5. Create a bar or pie chart for the results of the previous exercise.
End of explanation
"""


oly.weightlifting_classes()

"""
Explanation: 6. Male weightlifting competitions are divided into 8 weight classes. Can you estimate these weight classes by looking at the data? Hint: Create a scatter plot with Body weight on the x-axis and choose height as y.
End of explanation
"""


oly.height_histograms()

"""
Explanation: The predicted weight classes are displayed in text boxes outlined in crimson.
7. Generate a histogram of male and female height distribution among all participants.
End of explanation
"""


oly.height_boxplot()

"""
Explanation: 8. Using the Seaborn package create a box plot for male and female height distribution among all participants.
End of explanation
"""


oly.height_sport()

"""
Explanation: 9. Optional: What else would you try?

Compare type of medal compared to height.
Compare type of medal compared to weight.
Compare height vs age.
Are younger generation people taller or are Olympic athletes in the top percentile irregardless?


Which sport distributes the most medals.
Calculate the Body Mass Index (BMI) of the athletes.
Compare the BMI by sport.


Find the athlete that is closest to your height and mass.
Compare male and female heights for each sport.
End of explanation
"""


