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 panel as pn # GUI | |
pn.extension() | |
def get_completion(prompt, model="gpt-3.5-turbo"): | |
messages = [{"role": "user", "content": prompt}] | |
response = openai.ChatCompletion.create( | |
model=model, | |
messages=messages, | |
temperature=0, # this is the degree of randomness of the model's 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
# filtrar ano mais recente | |
df_idhm = df_idhm[df_idhm['ANO'] == np.max(df_idhm['ANO'])] | |
# selecionar colunas | |
df_idhm = df_idhm[['Codmun7', 'IDHM']] | |
# renomear colunas | |
df_idhm.columns = ['cod_municipio', 'idhm'] | |
df_idhm.head() |
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
def correl_df(dframe): | |
correl_matrix = dframe.corr() | |
# Select upper triangle of correlation matrix | |
upper = correl_matrix.where(np.triu(np.ones(correl_matrix.shape), k=1).astype(np.bool)).head() | |
upper = upper.unstack().reset_index() | |
# rename columns | |
upper.columns = ['var1', 'var2', 'correl'] | |
# drop na | |
upper = upper.dropna() | |
upper['correl_abs'] = np.abs(upper['correl']) |
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
library(spotifyr) | |
library(tidyverse) | |
Sys.setenv(SPOTIFY_CLIENT_ID = '') | |
Sys.setenv(SPOTIFY_CLIENT_SECRET = '') | |
xml <- read_html("https://developer.spotify.com/documentation/general/guides/scopes/") | |
scopes <- xml %>% html_nodes("code") %>% html_text() %>% unique() | |
auth <- get_spotify_authorization_code(scope = scopes) |
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
# baixar dados | |
library(tidyverse) | |
library(foreign) | |
library(readxl) | |
library(janitor) | |
library(fuzzyjoin) | |
# download.file("http://www.metro.sp.gov.br/pesquisa-od/arquivos/Pesquisa-Origem-Destino-2017-Banco-Dados.zip", | |
# destfile = "od.zip") | |
# |
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
library(tidyverse) | |
library(jsonlite) | |
library(UpSetR) | |
#### imdb data #### | |
# Fonte: https://www.imdb.com/interfaces/ | |
imdb_title_akas <- read_delim("data/imdb/title.akas.tsv.gz", | |
delim = "\t", | |
na = c("", "\\N")) |
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
library(rvest) | |
library(stringr) | |
url_zap <- 'https://www.zapimoveis.com.br/aluguel/apartamentos/sp+sao-paulo/?__zt=ad:a' | |
xml2::read_html("https://www.zapimoveis.com.br/") | |
html_obj <- httr::GET(url_zap) %>% | |
read_html() |
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
# http://r-br.2285057.n4.nabble.com/R-br-Ler-MAP-no-R-Shapefile-td4661880.html | |
# http://www2.datasus.gov.br/DATASUS/tabwin/DocTabWin.htm | |
# http://datasus.saude.gov.br/versao-3 | |
# http://www2.datasus.gov.br/DATASUS/tabwin/rx/Importa_mapa.htm | |
# http://datasus.saude.gov.br/cadastros-nacionais/294-download-mapas-tabwin | |
read.map = function(filename){ | |
zz=file(filename,"rb") | |
# |
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
library(httr) | |
library(magrittr) | |
library(xml2) | |
library(rvest) | |
url_raw <- "http://dados.cvm.gov.br/dados/FI/DOC/INF_DIARIO/DADOS/" | |
output_file <- "fundos/api/informe_diario.csv" | |
csv_links <- httr::GET(url_raw) %>% | |
httr::content("text") %>% |
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
# adaptacao da planilha de valuation da proseek | |
library(dplyr) | |
library(purrr) | |
library(magrittr) | |
#### párametros unicos | |
taxa_impostos_indiretos <- 14.65/100 | |
margem_estimada <- 19.78/100 | |
taxa_ir_base <- 8/100 |
NewerOlder