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
# From m/d/yyyy text to yyyy-mm-dd text. | |
=SUBSTITUTE(RIGHT(A4;4)&"-"&IF(LEN(A4)>9;LEFT(A4;2);"0"&LEFT(A4;1))&"-"&MID(A4;FIND("/";A4)+1;2);"/";"") | |
# From m/d/yyyy text to yyyy-mm-dd date. | |
=DATEVALUE(SUBSTITUTE(RIGHT(A4;4)&"-"&IF(LEN(A4)>9;LEFT(A4;2);"0"&LEFT(A4;1))&"-"&MID(A4;FIND("/";A4)+1;2);"/";"")) | |
# From text 3.5 to 3,50 number | |
=VALUE(SUBSTITUTE(B5;".";",")) |
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
datos <- structure(list(Genero = c(2, 1, 1, 2, 1, 1, 1, 2, 2, 2), | |
`1. En casa` = c(1, 3, 1, 3, 4, 2, 4, 5, 5, 5), | |
`2. Con la tele` = c(4, 2, 1, 2, 3, 3, 2, 1, 1, 1)), | |
row.names = c(NA, -10L), | |
class = c("tbl_df", "tbl", "data.frame")) | |
# Opción con stats::wilcox.test | |
datos |> | |
dplyr::select(-Genero) |> | |
purrr::map_df(function(x){ |
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
```{python} | |
import csv | |
import requests | |
import time | |
# Open the CSV file and read the data | |
with open('data.csv', 'r') as file: | |
reader = csv.reader(file) | |
data = [row for row in reader] |
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
from selenium import webdriver | |
from selenium.webdriver.chrome.service import Service | |
from webdriver_manager.chrome import ChromeDriverManager | |
from selenium.webdriver.chrome.options import Options | |
from selenium.webdriver.support.ui import WebDriverWait | |
from selenium.webdriver.support import expected_conditions as EC | |
from selenium.webdriver.common.by import By | |
import time | |
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
from typing import Callable | |
from functools import reduce, partial | |
add_three = lambda x: x+3 | |
duplicate = lambda x: x*2 | |
#------- | |
ComposableFunction = Callable[[float], float] |
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
<html><body> | |
<script> | |
function handle() { | |
console.log("handle") | |
window.myPolling = setTimeout(finish, 2000); | |
} | |
function finish() { | |
console.log("finish") | |
} | |
function fireAttribute(){ |
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
kgl_competitions_data_download <- function(competition_id, file_name, path = ".") { | |
.kaggle_base_url <- "https://www.kaggle.com/api/v1" | |
url <- paste0(.kaggle_base_url, "/competitions/data/download/", competition_id, "/", file_name) | |
rcall <- httr::GET(url, httr::authenticate(Sys.getenv("KAGGLE_USER"), Sys.getenv("KAGGLE_KEY"), type = "basic")) | |
tmp <- tempfile() | |
download.file(rcall$url, tmp) | |
invisible(file.copy(tmp, paste0(path, "/", file_name))) | |
} |
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
#' Execute f for each row of df | |
#' | |
#' @param df data.frame | |
#' @param f function | |
#' @return A data.frame with the result of executin g for each row of df. | |
#' @examples | |
#' row_split_map( | |
#' tibble(x = c(1, 2), y = c(2, 3)), | |
#' function(df) { | |
#' df %>% mutate( |
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
# Load libraries | |
library(tidyverse) | |
# Original names | |
df <- tibble(Q1=c(1), Q2=c(1), Q3=c(1), Q4=c(1), Q5=c(1), Q6=c(1), Q7=c(1), Q25_1=c(1), Q25_2=c(1), Q25_3=c(1), Q25_4=c(1), Q25_5=c(1), Q25_6=c(1), Q25_7=c(1), Q25_8=c(1), Q25_9=c(1), Q25_10=c(1), Q25_11=c(1), Q25_12=c(1), Q25_13=c(1), Q25_14=c(1), Q25_15=c(1), Q25_16=c(1), Q26_1=c(1), Q26_2=c(1), Q26_3=c(1), Q26_4=c(1), Q26_5=c(1), Q26_6=c(1), Q26_7=c(1)) | |
df %>% glimpse() | |
# Option A) Using select and rename_with | |
df %>% | |
select( |
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(rvest) | |
library(xml2) | |
get_attrs <- function(df) { | |
ret <- | |
map(df, ~xml_attrs(df)) %>% | |
bind_rows %>% | |
rename(tipus = scheme) | |
ret |