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
#' num_bkts should be a non-zero integer | |
#' col should contain numeric values | |
equi_bucket <- function(col, num_bkts){ | |
if(!is.numeric(col)){ | |
warning("Values passed to Equibucket are not numeric") | |
return(NA) | |
} | |
xmin = min(col, na.rm = TRUE) | |
eps = 1/(num_bkts-1) |
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
plot_pax_wrap <- function(df, num_pax){ | |
pax_rows <- round(sqrt(num_pax), -1) | |
pax_cols <- as.integer(num_pax/pax_rows) | |
df2 <- arrange(df, -Rev) | |
curr_pax <- 1 | |
for (py in 1:pax_cols){ | |
for (px in 1:pax_rows){ | |
if (curr_pax <= num_pax){ | |
df2[curr_pax, 'plot_col'] = px |
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 json | |
from wordcloud import WordCloud | |
import matplotlib.pyplot as plt | |
with open('data/trump_tweets/condensed_2018.json') as f: | |
data = json.load(f) | |
type(data), len(data) |
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
w, h = 800, 800 | |
def setup(): | |
size(w, h) | |
stroke(0, 0, 250) # blue | |
num_steps = 200 | |
step = TWO_PI / num_steps |
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
w, h = 1000, 800 | |
class Ball(object): | |
def __init__(self,_id, _x, _y, _vx=0, _vy=0, _dir='UP'): | |
self.x, self.y = _x, _y | |
self.vx, self.vy = _vx, _vy | |
self.id = _id | |
self.dir = _dir #'UP', 'DOWN', "RIGHT", "LEFT" | |
self.av = 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
# The noise value was calculated at each pixel, | |
# using Processing’s built-in noise function. | |
# This value was scaled up (by a factor of 10 to 100) and rounded, | |
# yielding an integer for every pixel in the frame. | |
# Colors were designated based on this number using a switch. | |
# Finally, a point/dot was drawn at each pixel, in the assigned color. | |
# The greater the scaling factor, the thinner and more numerous the noise bands. | |
# Creates a 2D List of 0's, nCols x nRows large |
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
class Ball(object): | |
def __init__(self,_id, _x, _y, _vx=0, _vy=0): | |
self.x, self.y = _x, _y | |
self.vx, self.vy = _vx, _vy | |
self.id = _id | |
#store the starting coords of each ball. For relaunching. | |
self.startx, self.starty = _x, _y | |
self.active = False | |
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
radius = 100 | |
def setup(): | |
size(800, 600) | |
background(255) | |
smooth() | |
noStroke() | |
fill(0, 0, 200) | |
frameRate(100) | |
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 | |
def print_songs_found(songs_column, clue_words): | |
for song in songs_column: | |
try: | |
songwords = [x.lower() for x in song.split()] | |
#print(songwords) | |
if all(word in clue_words for word in songwords): | |
print(songwords) | |
except: |
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
i <- 1:50 | |
b <- 1:5 | |
ColNames <- paste0("X_", i, "_", rep(b, each=length(i))) |
NewerOlder