This file contains hidden or 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
| tmux ls | grep : | cut -d. -f1 | awk '{print substr($1, 0, length($1)-1)}' | xargs kill |
This file contains hidden or 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
| -- Tables + Size MB | |
| select owner, table_name, round((num_rows*avg_row_len)/(1024*1024)) MB | |
| from all_tables | |
| where owner not like 'SYS%' -- Exclude system tables. | |
| and num_rows > 0 -- Ignore empty Tables. | |
| order by MB desc -- Biggest first. | |
| ; |
This file contains hidden or 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(purrr) | |
| list( | |
| c(1,2,3,4, NA), | |
| c(5,6,7, NA, NA), | |
| c(12,12, 12, NA, NA), | |
| c(3, NA) | |
| ) %>% modify_depth(1, ~keep(.x = ., .p = ~!is.na(.))) | |
This file contains hidden or 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(rpart) | |
| library(tidyverse) | |
| library(ggdendro) | |
| ggplot(data = iris, | |
| aes(Sepal.Length, Petal.Length, color = Species))+ | |
| geom_point() | |
| dt <- rpart(Species ~ Sepal.Length + Petal.Length, | |
| data = iris, |
This file contains hidden or 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
| add_lagged <- function(df, var, n = 1) { | |
| var <- enquo(var) | |
| names <- map(1:n, ~ paste0(quo_name(var), '_lag_' ,.)) | |
| lagged_cols <- map2(1:n, names, ~ df %>% transmute(!!.y := lag(!!var, n = .x))) %>% | |
| bind_cols() | |
| df %>% bind_cols(lagged_cols) | |
| } |
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
This file contains hidden or 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
| col | |
| 1 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 3 | |
| 2 |
This file contains hidden or 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 | |
| from pathlib import Path | |
| from functools import wraps | |
| def cache_pandas_result(cache_dir, hard_reset: bool): | |
| ''' | |
| This decorator caches a pandas.DataFrame returning function. | |
| It saves the pandas.DataFrame in a parquet file in the cache_dir. | |
| It uses the following naming scheme for the caching files: |
This file contains hidden or 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(broom) | |
| df <- | |
| tibble( | |
| label = factor(c(rep("group1", 8E4), rep("group2", 1E4))), | |
| var = c(rnorm(n = 8E4, mean =2, sd= 5), c( rnorm(n = 5E3,mean =-2, sd= 0.5), rnorm(n=5E3, mean = 1, sd = 0.5))) | |
| ) |
This file contains hidden or 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(broom) | |
| df <- | |
| tibble( | |
| label = factor(c(rep("group1", 8E4), rep("group2", 1E4))), | |
| var = c(rnorm(n = 8E4, mean =2, sd= 5), c( rnorm(n = 5E3,mean =-2, sd= 0.5), rnorm(n=5E3, mean = 1, sd = 0.5))) | |
| ) |
This file contains hidden or 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(ggalt) | |
| library(hrbrthemes) | |
| library(tidyverse) | |
| structure(list(district = structure(13:1, .Label = c("E.D. New York", | |
| "D. New Jersey", "W.D. Wisconsin", "D. Delaware", "S.D. Florida", | |
| "N.D. Illinois", "M.D. Florida", "S.D. New York", "D. Connecticut", | |
| "D. Maryland", "N.D. California", "N.D. Georgia", "C.D. California" | |
| ), class = "factor"), `2017` = c(0.14, 0.16, 0.14, 0.01, 0.01, | |
| 0.04, 0.04, 0.04, 0.03, 0.01, 0.01, 0.06, 0.03), `2018` = c(0.26, |