<jupyter_start><jupyter_text>Subplots<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

%matplotlib inline
df = pd.read_csv('C:\\Series_Temporais\\UDEMY_TSA_FINAL\\life_expectancy.csv')
df.head()
# Conferindo os valores unicos do meu dataset
df['Country'].unique()
# Excluindo a coluna Unnamed: 0
df.drop('Unnamed: 0', axis=1, inplace=True)
df.head(20)
# Filtrando os dados
df_brasil = df[df['Country'] == 'Brazil']
df_brasil
# Filtrando os dados
df_eua = df[df['Country'] == 'EUA']
df_eua<jupyter_output><empty_output><jupyter_text>Subplots<jupyter_code># Retorna uma figura e um axes
figure, axes = plt.subplots(nrows=1, ncols=2, figsize=(14,5))


axes[0].plot(df_brasil['Year'], df_brasil['Life Expectancy'], marker='o')
axes[0].set_xlabel('Ano')
axes[0].set_ylabel('Expectativa de Vida')
axes[0].set_title('Dados do Brasil')

axes[1].plot(df_eua['Year'], df_eua['Life Expectancy'], marker='o')
axes[1].set_xlabel('Ano')
axes[1].set_ylabel('Expectativa de Vida')
axes[1].set_title('Dados dos Estados Unidos')
figure, axes = plt.subplots(nrows=2, ncols=1, figsize=(12,8))


axes[0].plot(df_brasil['Year'], df_brasil['Life Expectancy'], marker='o')
axes[0].set_xlabel('Ano')
axes[0].set_ylabel('Expectativa de Vida')
axes[0].set_title('Dados do Brasil')

axes[1].plot(df_eua['Year'], df_eua['Life Expectancy'], marker='o')
axes[1].set_xlabel('Ano')
axes[1].set_ylabel('Expectativa de Vida')
axes[1].set_title('Dados dos Estados Unidos')

plt.tight_layout()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1773981603153745, 'fraction_numerical': 0.020367936925098553, 'mean_word_length': 8.343558282208589, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '636454', 'license': 'MIT', 'n_tokens_mistral': 644, 'n_tokens_neox': 612, 'n_words': 112, 'path': 'pacote-download/Subplots - Youtube.ipynb', 'repo_name': 'stephacastro/Coleta_dados', 'size': '1522'}