<jupyter_start><jupyter_text>Exercise 2- load: ../data/weight-height.csv- inspect it- plot it using a scatter plot with Weight as a function of Height- plot the male and female populations with 2 different colors on a new scatter plot- remember to label the axes<jupyter_code>import numpy as np

%matplotlib inline
import matplotlib.pyplot as plt

import pandas as pd
df = pd.read_csv('../../data/weight-height.csv')
df.info()
df.head()
# permite saber la cantidad de elementos por columna
df['Gender'].value_counts()
# graficamos solamente dos columnas
df.plot(kind='scatter', x='Height', y='Weight')
# recuperamos lo valores de la columna "Male" en un nuevo datafram
male = df.query('Gender == "Male"')

# recuperamos los valores de la columna "Female" en un nuevo dataframe
female = df.query('Gender == "Female"')

# armamos los subplots
fig, ax = plt.subplots()

# graficamos
male.plot(kind='scatter', x='Height', y='Weight', ax=ax, color='green', alpha=0.3)
female.plot(kind='scatter', x='Height', y='Weight', ax=ax, color='pink', alpha=0.3, title='Male and Female')
# otra solución posible es generar una nueva columna dentro del dataframe existente
df['GenderColor'] = df['Gender'].map({'Male': 'blue', 'Female': 'red'})
df.head()
df.plot(kind='scatter', x='Height', y='Weight', c=df['GenderColor'], alpha=0.3, title='Versión 2')<jupyter_output><empty_output><jupyter_text>Exercise 3- plot the histogram of the heights for males and for females on the same plot- use alpha to control transparency in the plot comand- plot a vertical line at the mean of each population using plt.axvline()<jupyter_code>male['Height'].plot(kind='hist',
                     bins=50,
                     range=(50, 80),
                     alpha=0.3,
                     color='blue')

female['Height'].plot(kind='hist',
                       bins=50,
                       range=(50, 80),
                       alpha=0.3,
                       color='red')

# agregamos algunos datos al gráfico
plt.title('Height distribution')
plt.legend(["Male", "Female"])
plt.xlabel("Heigth (in)")

# para crear las líneas verticales
plt.axvline(male['Height'].mean(), color='blue', linewidth=2)
plt.axvline(female['Height'].mean(), color='red', linewidth=2)<jupyter_output><empty_output><jupyter_text>Exercise 4- plot the weights of the males and females using a box plot- which one is easier to read?- (remember to put in titles, axes and legends)<jupyter_code># usaremos una tabla pivot
dfpvt = df.pivot(columns  = 'Gender', values = 'Weight')
dfpvt.head()
# graficamos
dfpvt.plot(kind='box')
plt.title('Weight Box Plot')
plt.ylabel('weight(lbs)')<jupyter_output><empty_output><jupyter_text>Exercise 5- load the dataset: `../data/titanic-train.csv`- learn about scattermatrix here: http://pandas.pydata.org/pandas-docs/stable/visualization.html- display the data using a scattermatrix<jupyter_code>df_titanic = pd.read_csv('../../data/titanic-train.csv')
df_titanic.info()
df_titanic.head()
from pandas.plotting import scatter_matrix
# gráfico de matriz, nos permite comparar todas las columnas
_ = scatter_matrix(df_titanic.drop('PassengerId', axis=1), figsize=(10,10))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1393596986817326, 'fraction_numerical': 0.01098556183301946, 'mean_word_length': 4.347315436241611, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '315920', 'license': 'MIT', 'n_tokens_mistral': 1108, 'n_tokens_neox': 1033, 'n_words': 295, 'path': 'mis_soluciones/data/Excersice_2.ipynb', 'repo_name': 'viccmedina/deep_learning', 'size': '3186'}