<jupyter_start><jupyter_text>Análisis del nacimiento de bebés en US<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
births = pd.read_csv("../../data/us-births.csv")
births.shape
births.head()
births.tail()
births.pivot_table('births', index = 'year', columns='gender', aggfunc='sum')
births['decade'] = (births['year']//10)*10
births.head()
births.pivot_table('births', index='decade', columns='gender', aggfunc='sum')
%matplotlib inline
import seaborn as sb
sb.set()
plt.figure(figsize=(15, 8))
births.pivot_table('births', index='year', columns='gender', aggfunc="sum").plot()
plt.ylabel("Total de Nacimientos por Año")
plt.show()
quartiles = np.percentile(births['births'], [25,50,75])
quartiles
med = quartiles[1]
IQR = quartiles[2]-quartiles[0]
sig = 0.75*IQR
births = births.query("(births > @med - 5*@sig) & (births < @med + 5*@sig)")
births.shape
births['day'] = births['day'].astype(int)
births.head()
births.index = pd.to_datetime(10000*births.year+100*births.month+births.day, format="%Y%m%d")
births.head()
births['dayofweek'] = births.index.dayofweek
births.head()
births.pivot_table('births', index='dayofweek', columns='decade', aggfunc="mean")
births.pivot_table('births', index='dayofweek', columns='decade', aggfunc="mean").plot()
plt.gca().set_xticklabels(['', "Lun", "Mar", "Mie", "Jue", "Vie", "Sab", "Dom"])
plt.ylabel("Media de nacimientos por día")
plt.show()
births_by_date = births.pivot_table('births', index=[births.index.month, births.index.day], aggfunc="mean")
births_by_date.head()
births_by_date.index = [pd.datetime(2020, month, day) 
                        for (month, day) in births_by_date.index]
births_by_date.head()
plt.figure(figsize=(12,4))
births_by_date.plot()
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19304152637485972, 'fraction_numerical': 0.020202020202020204, 'mean_word_length': 6.8201754385964914, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '173995', 'license': 'MIT', 'n_tokens_mistral': 775, 'n_tokens_neox': 683, 'n_words': 123, 'path': 'scripts/tema9/03-us-births.ipynb', 'repo_name': 'Adipiz/EstadisticaDescriptiva', 'size': '1782'}