Skip to content

Instantly share code, notes, and snippets.

View ClintWeathers's full-sized avatar

Clint Weathers ClintWeathers

  • Target
  • Minneapolis, MN
View GitHub Profile
@ClintWeathers
ClintWeathers / ubuntu_thing.md
Created July 24, 2018 03:46
Getting The Ubuntu Thing Working

The Main Idea

Get a datascience environment built on a VM.

In theory, this gives me a few things:

  • The umph of my overbuilt desktop machine minus a few gig of ram and a couple cores
  • The ability to SSH/VNC/RDP in and just use my chromebook as a cheap thin client when Im out and about.
  • Experience dealing with the install and usage of Drill, Zeppelin, and some other tools.

So far I've:

  1. Downloaded the Bionic ubuntu iso
# List unique values in a DataFrame column
# h/t @makmanalp for the updated syntax!
df['Column Name'].unique()
# Convert Series datatype to numeric (will error if column has non-numeric values)
# h/t @makmanalp
pd.to_numeric(df['Column Name'])
# Convert Series datatype to numeric, changing non-numeric values to NaN
# h/t @makmanalp for the updated syntax!
@ClintWeathers
ClintWeathers / Jupyter_Busy_Indicator.txt
Created June 27, 2016 15:15
How to change Jupyter notebook busy indicator to something more visible
Most of this is just following the steps here:
http://sherifsoliman.com/2016/01/11/theming-ipython-jupyter-notebook/
On a recent Juypter version, open up the custom.css in your favorite editor which should be Sublime Text 3 or Vim and definitely not emacs.
~/.jupyter/custom/custom.css (on my VM this lives in C:\Users\username\.ipython\profile_default\static\custom -- YMMV)
Do a search for kernel_busy_icon
@ClintWeathers
ClintWeathers / dplyrwoes.txt
Created December 10, 2015 21:35
Aggregation using Dplyr
library(dplyr); library(magrittr)
#To Create The Dataframe of Fake Orders
set.seed(867.5309)
onums <- paste("AA", as.integer(runif(20) * 1e8), sep = "")
prices <- round((runif(20) * 1000), 2)
orders <- as.data.frame(cbind(onums, prices))
@ClintWeathers
ClintWeathers / readr_crash.txt
Created December 9, 2015 21:23
readr crash during read_csv()
> may_2015 <-
+ read_csv(
+ "Z:/data_CSVs/thingsandstuff_files/may2015.csv"
+ )
Assertion failed!
Program: C:\Users\ahm0\Documents\RStudio\bin\rsession.exe
File: d:/RCompile/CRANpkg/lib/3.2/BH/include/boost/spirit/home/support/detail/pow10.hpp, Line 87
Expression: dim < sizeof(exponents)/sizeof(double)
@ClintWeathers
ClintWeathers / ggvisdensitycrash.R
Created November 21, 2015 21:02
fill + opacity in layer_densities() causes crash in ggvis
# Started from here, an example from Hadley Wickham in the google groups https://groups.google.com/forum/#!topic/ggvis/AJZCdjFcNaE.
# Using R 3.2.1 x86_64, ggvis 0.4.2.
cocaine %>%
ggvis( ~ potency, ~ price) %>%
filter(state %in% eval(input_checkboxgroup(c("IA", "MN", "WI"),
selected = "WI"))) %>%
layer_points(fill = ~ state, size := 50, opacity := 0.5)
# This works fine and evals the way one would expect.
@ClintWeathers
ClintWeathers / dplyrstuff.R
Last active December 24, 2017 03:05
Trying to make a new dataframe using Dplyr
### Trying to create new dataframes from dplyr 0.4.3 functions using R 3.2.2.
#Very Simple Example:
paste("cars_with", 6, "cylinders", sep = "_") <- filter(mtcars, cyl == 6)
#What I want there is a dataframe named "cars_with_6_cylinders" that has the results of this:
filter(mtcars, cyl == 6)
#But instead, what I get is this:
@ClintWeathers
ClintWeathers / rmdweirdness.Rmd
Created November 19, 2015 21:50
Weirdness in RMarkdown/Shiny
---
title: "Testing1"
author: "JCW"
date: "November 19, 2015"
output:
html_document:
highlight: haddock
theme: cosmo
---
@ClintWeathers
ClintWeathers / paramed_query.R
Last active November 4, 2015 21:51
paramaterized query using ldply.R
library(RODBC)
library(RODBCext)
dbconn <- odbcConnect(dsn = "dbname", uid = "me", pwd = "password")
query <- "select * from table where blah = 'blahblahblah' and blah2 = ?"
results <- function(x){
sqlExecute(dbconn, query, x)
sqlGetResults(dbconn)
}
@ClintWeathers
ClintWeathers / gist:60c1333ef46220ed355b
Created August 18, 2015 13:27
Question Re Piping Inside A Function
It's not uncommon where I'm working to get some dataset with a needlessly longass name and needlessly longass field names.
Unfortunately, they want the field names and dataset names left as is, in situ.
Is there something like %>% for single-line stuff that would do this:
Instead of...
omgthisdatasetnameissolong$whythehelldidtheynamethisfieldlikethis <- as.character(omgthisdatasetnameissolong$whythehelldidtheynamethisfieldlikethis)
maybe this...