<jupyter_start><jupyter_text>Planejamento da solução: * Produto Final (o que eu vou entregar? Planilha, modelo de ML)    * Email + 3 anexos    * Arquivo .csv    * Mapa com filtros requisitados    * Dashboard com os filtros requisitados* Ferramentas (qual a ferramenta que eu vou usar?)* Processo (Como fazer?)<jupyter_code>import pandas as pd
from geopy.geocoders import  Nominatim
import plotly.express as px
import ipywidgets as widgets
from ipywidgetes import fixed
from matplotlib import gridspec
from matplotlib import pyplot as plt
df1 = pd.read_csv(r'C:\Users\06564176686\repos\House_Rocket_EDA\data')



    
geolocator = Nominatim( user_agent='geoapiExercises' )

response = geolocator.reverse('45.5112, -122.2566651')
print( response.raw['address']['road'])
print( response.raw['address']['road'])
print( response.raw['address']['road'])
print( response.raw['address']['road'])
print( response.raw['address']['road'])
print( response.raw['address']['state'])
df1 = pd.read_csv('C:\Users\06564176686\repos\House_Rocket_EDA\data.csv')

df1['road'] = 'NA'
df1['house_number'] = 'NA'
df1['city'] = 'NA'
df1['county'] = 'NA'
df1['state'] = 'NA'

# API request
geolocator = Nominatim( user_agent='geoapiExercises' )
response = geolocator.reverse('45.5112, -122.2566651')




df1.loc[0, 'house_number']  = response.raw['address']['house_number']
df1.loc[0, 'road']          = response.raw['address']['road']
df1.loc[0, 'nighborudhood'] = response.raw['address']['neighbourhood']
df1.loc[0, 'city']          = response.raw['address']['city']
df1.loc[0, 'county']        = response.raw['address']['county']
df1.loc[0, 'state']         = response.raw['address']['state']<jupyter_output><empty_output><jupyter_text>Filtros iterativos no mapa<jupyter_code>df1 = pd.read_csv('C:\Users\06564176686\repos\House_Rocket_EDA\data')
houses = df1[['id, 'lat', 'long, 'price']].copy()

#popular houses com 'level' 0, 1,2,3 conforme price


# fazer mapa
fig = px.scatter_mapbox(houses,
                        lat='lat',
                        lon = 'long',
                        color='level',
                        size = 'price',
                        color_continuous_scale = px.colors.cyclical.IceFire,
                        size_max=15,
                        zoom=10)

fig.update_layout( mapbox_style='open-stree3t-map')
fig.update_layout( height=600, margin={'r':0, 't':0, 'l':0, 'b':0})
fig.show()

                       


# Adicionando filtros iterativos

style = {'description_width': 'initial'}

price_limit = widgets.IntSlider(
    value = 540000,
    min = 75000,
    max = 77000000,
    step = 1,
    description= 'Maximum Price',
    disable = False,
    style = style)

waterfront_bar = widgets.Dropdown(
    options = df1['is_waterfront'].unique().tolist(),
    value='yes'
    description='Water View',
    disable=False)
# Iteratividade com o dashboard

# change date format

df['year'] = pd.to_datetime( df['date']).dt.strftime('%Y')
df['date'] = pd.to_datetime( df['date']).dt.strftime('%Y-%m-%d')
df['year_week'] = pd.to_datetime( df['date']).dt.strftime('%Y-%U')

# widgets to control data
data_limit = widgets.SelectionSlider(
    options = df['date'].sort_values().uniques().tolist(),
    value = '2014-12-01',
    description = 'Disponivel',
    continuous_update = False,
    orientation= 'horizontal',
    readout=True
)

def update_map(data, limit):
    #filter data
    df = data[data['date'] >= limit].copy()
    
    fig = plt.figure(figsize= (21,12))
    specs = gridspec.GridSpec(ncols=2, nrows=2, figure = fig)
    
    ax1 = fig.add_subplot(specs[0,:])
    ax2 = fig.add_subplot(specs[1,0]) 
    ax3 = fig.add_subplot(specs[1,1])
    
    by_year = df[['id', 'year']].groupby('year').sum().rest_index()
    ax1.bar( by_year['year'], by_year['id'])
    
    by_day = df[['id', 'year']].groupby('date').mean().reset_index()
    ax2.plot( by_day['date'], by_day['id'])
    ax2.set_title('title: Avg Price by Day')
    
    by_week = df[['id', 'year_week']].groupby('year_week').sum().reset_index()
    ax3.bar( by_week['year_week'], by_week['id'])
    ax3.set_title('title: Avg Price by Week of Year')
    
    plt.xticks( rotation=60)

widgets.interactive(update_map, data=fixed(df), limit = date_limit)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17057169634489222, 'fraction_numerical': 0.03584817244611059, 'mean_word_length': 3.796629213483146, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, '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': '221887', 'license': 'MIT', 'n_tokens_mistral': 1635, 'n_tokens_neox': 1528, 'n_words': 288, 'path': 'House.ipynb', 'repo_name': 'enerdb/House_Rocket_EDA', 'size': '4268'}