This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Install Ubuntu for windows on Microsoft Store | |
#Path: https://www.microsoft.com/pt-br/store/p/ubuntu/9nblggh4msv6 | |
# Install Oracle JDK 8 | |
add-apt-repository ppa:webupd8team/java | |
apt-get update | |
apt-get install -y oracle-java8-installer | |
apt-get install -y unzip make | |
#Install Linux dependecies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#importa a biblioteca Pandas | |
import pandas as pd | |
#Cria um DataFrame simples | |
df = pd.DataFrame([0,1,2,3,4,5],columns=["teste"]) | |
#Imprime este dataframe no terminal | |
print (df) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dash | |
import dash_core_components as dcc | |
import dash_html_components as html | |
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] | |
app = dash.Dash(__name__, external_stylesheets=external_stylesheets) | |
app.layout = html.Div(children=[ | |
html.H1(children='Hello Dash'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.callback( | |
Output(component_id='my-div', component_property='children'), | |
[Input(component_id='my-id', component_property='value')] | |
) | |
def update_output_div(input_value): | |
return 'You\'ve entered "{}"'.format(input_value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import dash | |
import dash_core_components as dcc | |
import dash_html_components as html | |
from dash.dependencies import Input,Output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#colunas que serão utilizadas | |
cols = ['mesano_de_referencia','tribunal','cargo','total_de_rendimentos'] | |
#carregar dataset salários | |
df_salarios = pd.read_csv("datasets/salarios.csv",usecols=cols,low_memory=False) | |
#instanciando dash app | |
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] | |
app = dash.Dash(name=__name__,external_stylesheets=external_stylesheets) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#criação do layout | |
app.layout = html.Div([ | |
#menu dropdown com a id para ser acessado via callback e a lista de opções geradas a partir do dataframe | |
dcc.Dropdown( | |
id='tribunal-dropdown', | |
options=[{'label':i,'value':i} for i in tribunal] | |
), | |
#div para a exibição do gráfico. Repare que o elemento graph só tem o ID, o gráfico será gerado no callback | |
html.Div([ | |
dcc.Graph( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#criando uma lista com os nomes de tribunais existentes no dataset | |
tribunal = df_salarios.tribunal.unique() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#neste callback utilizaremos como Output o Graph "meu-grafico-aqui" | |
#como Input recebemos o valor ativo no menu Dropdown (value) | |
@app.callback( | |
Output('meu-grafico-aqui','figure'), | |
[Input('tribunal-dropdown','value')] | |
#Após o callback, teremos a função que fará o update no output de acordo com o valor (value) recebido (sacou?!?!) | |
def update_output(value): | |
#aqui criaremos um novo dataframe que será filtrado conforme o tribunal selecionado | |
#o resultado será agrupado pela data de pagamento utilizando a soma dos valores | |
#ao final, resetamos o índice para a geração do gráfico |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fig = px.bar(player_nat,x='preferred_foot',y='sofifa_id',labels={ | |
'preferred_foot': 'Pé preferido para o chute', | |
'sofifa_id': 'Total de Jogadores' | |
}) | |
fig.show() | |
OlderNewer