# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + [markdown] id="view-in-github" colab_type="text"
# <a href="https://colab.research.google.com/github/albertomendess/Data-Science/blob/main/Criando_Agrupamentos.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>

# + [markdown] id="KYfzS8gZ1qCd"
# # Relatório de Análise VII

# + id="O8KBPPpKwXqH"
import pandas as pd

# + colab={"base_uri": "https://localhost:8080/", "height": 254} id="Uul4mehi0Vvl" outputId="5b80235a-902c-42f5-b935-20b486126d8e"
dados = pd.read_csv('/content/aluguel.csv', sep= ';')
dados.head(7)

# + id="imTvAKvY1zXn"
bairros = ['Barra da Tijuca', 'Copacabana', 'Ipanema', 'Leblon',
           'Botafogo', 'Flamengo', 'Tijuca']

selecao = dados['Bairro'].isin(bairros)
dados = dados[selecao]

# + colab={"base_uri": "https://localhost:8080/"} id="fXKZw-ff2tpr" outputId="ad31ad36-2f39-4f73-9257-16853c021b31"
dados['Bairro'].drop_duplicates()

# + colab={"base_uri": "https://localhost:8080/"} id="br3eKpDI20lW" outputId="4e9c6f88-e6a5-4c7d-fbff-a82da9f13141"
grupo_bairro = dados.groupby('Bairro')
type(grupo_bairro)

# + colab={"base_uri": "https://localhost:8080/"} id="FyfDXS_H286N" outputId="31003c22-a864-4c56-8c62-8e633ed36328"
for bairro, data in grupo_bairro:
    print('{} -> {}'.format(bairro, data.Valor.mean()))

# + colab={"base_uri": "https://localhost:8080/"} id="tH4F_0NY3DxS" outputId="f3995643-6946-4c26-beef-1a880f7647dc"
grupo_bairro['Valor'].mean().round(2)

# + [markdown] id="uKrN4QjI9bvY"
# # Estatíscas Descritivas

# + colab={"base_uri": "https://localhost:8080/", "height": 284} id="bMOMxkLZ9bAb" outputId="4f789ec8-2f93-4193-ae69-a9e5009d9be5"
grupo_bairro['Valor'].describe().round(2)

# + colab={"base_uri": "https://localhost:8080/", "height": 284} id="kxfg65Cf9rcW" outputId="a86ac180-75dc-4f0e-f0a8-93a68843ba17"
grupo_bairro['Valor'].aggregate(['min', 'max']).rename(columns = {'min': 'Minimo', 'max': 'Maximo'})

# + id="tMl5d_-k-RrR"
# %matplotlib inline
import matplotlib.pyplot as plt
plt.rc('figure', figsize= (20, 10))

# + colab={"base_uri": "https://localhost:8080/", "height": 712} id="RND4_92N_DJO" outputId="e59b1c2e-01bb-4cdd-e1f2-e419ee7a2ed6"
fig = grupo_bairro['Valor'].mean().plot.bar(color= 'blue')
fig.set_ylabel('Valor do Aluguel')
fig.set_title('Valor Médio do Aluguel por Bairro', {'fontsize': 22})

# + id="w0REBI9h_bs-"


StarcoderdataJupyterScriptsDedupFiltered