Skip to content

Instantly share code, notes, and snippets.

View jtrecenti's full-sized avatar
🎯
Focusing

Julio Trecenti jtrecenti

🎯
Focusing
View GitHub Profile
tibble::tibble()
tribunais <- forosCNJ::da_tribunal |>
dplyr::filter(id_justica == 8) |>
dplyr::pull(sigla) |>
tolower()
endpoints <- glue::glue(
"https://api-publica.datajud.cnj.jus.br/api_publica_{tribunais}/_search"
)
# Endpoint for SOAP requests
endpoint_url <- 'https://www.cnj.jus.br/corregedoria/justica_aberta/ws.php'
# XML payload, replace the method name and parameters as per actual API
# This is a simplified example assuming a SOAP method called 'getServentiaJudicial' that accepts 'seq_orgao' as a parameter
xml_payload <- '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cor="https://www.cnj.jus.br/corregedoria/justica_aberta/ws.php">
<soapenv:Header/>
<soapenv:Body>
<cor:pesquisarServentiasJudiciais>
<!--Optional:-->
# reciclou mas deu um warning porque não é múltiplo
tibble::tibble(x = c('a', 'b', 'c')) |>
dplyr::filter(x == c('a', 'b'))
#> Warning: There was 1 warning in `dplyr::filter()`.
#> ℹ In argument: `x == c("a", "b")`.
#> Caused by warning in `x == c("a", "b")`:
#> ! comprimento do objeto maior não é múltiplo do comprimento do objeto menor
#> # A tibble: 2 × 1
#> x
#> <chr>
# arrumação dos dados para pesquisa
moral_raw <- readxl::read_excel("moral.xlsx")
sexual_raw <- readxl::read_excel("sexual.xlsx")
moral <- moral_raw |>
janitor::clean_names() |>
dplyr::mutate(
no_processo_original = no_processo,
no_processo = abjutils::clean_cnj(no_processo)
pdf_full <- pdftools::pdf_text("pdf_full.pdf")
# 33-36, 38-39, 41-46, 48-49, 52-54, 56-61, 63-72, 74-77, 79-83, 85-91, 93-96, 98-100, 102-105
paginas <- c(
33:36, 38:39, 41:46, 48:49,
52:54, 56:61, 63:72, 74:77,
79:83, 85:91, 93:96, 98:100,
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 2. in line 1.
Category: All categories
Month,deu ruim: (Brazil)
2004-01,0
2004-02,0
2004-03,0
2004-04,0
2004-05,0
2004-06,0
2004-07,0
@jtrecenti
jtrecenti / gist:b39435913b0765c0ff1c1f2f9874dffc
Last active September 14, 2023 09:02
Exemplo simulado PSM
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LogisticRegression
# Seed for reproducibility
np.random.seed(42)
# Generate synthetic data
n = 500 # Number of samples
library(rugarch)
start_date <- '2018-01-01'
# esses são ativos de fundos imobiliários que eu ja tive
# e queria saber fiz um péssimo investimento
# ou apenas ruim.
ativos <- c(
"HGRE11.SA",
"BTLG11.SA",
"HGRU11.SA",
########################################
# Time-varying parameter CAPM
########################################
library(ggplot2)
library(BatchGetSymbols)
library(dplyr)
library(tidyr)
library(dlm)
ssp_criterios <- ssp_cortes %>%
mutate(corte = as.numeric(corte) / 10) %>%
gather(tipo_contagem, valor, maior, menor, total) %>%
unite(tipo_rubrica_contagem, tipo_rubrica, tipo_contagem, sep = "_") %>%
spread(tipo_rubrica_contagem, valor) %>%
mutate(soma = trafico_menor +
input$peso * porte_maior,
prop = trafico_menor / trafico_total +
input$peso * porte_maior / porte_total) %>%
group_by(droga_tipo) %>%