Skip to content

Instantly share code, notes, and snippets.

View broschke's full-sized avatar

Bernardo Roschke broschke

View GitHub Profile
@broschke
broschke / fizzbuzz.py
Created May 17, 2016 13:58
bernardo-fizzbuzz assignment
n = raw_input("Upper limit: ")
n = int(n)
for i in range(1,n):
if i % 3 == 0 and i % 5 == 0:
print 'fizz buzz'
elif i % 5 == 0:
print 'buzz'
elif i % 3 == 0:
print 'fizz'
class Musician(object):
def __init__(self, sounds):
self.sounds = sounds
def solo(self, length):
for i in range(length):
print(self.sounds[i % len(self.sounds)], end=" ")
print()
class Bassist(Musician): # The Musician class is the parent of the Bassist class
@broschke
broschke / Hello World Flask
Created June 25, 2016 15:46
Hello World using Flask with Jedi name
from flask import Flask
from os import environ
app = Flask(__name__)
@app.route("/")
@app.route("/hello")
def say_hi():
return "Hello World!"
@broschke
broschke / is_prime.py
Last active March 12, 2019 15:50
Python script that checks if a number is Prime
import math
user_num = raw_input("Enter a number: ")
num = int(user_num)
limit = int(math.sqrt(num))
result_list = []
for i in range(2,limit+1):
prime_test = num % i
import pandas as pd
from scipy import stats
def print_output(stat, val):
print("The {0} for the Alcohol and Tobacco dataset is {1}.".format(stat, val))
data = '''Region,Alcohol,Tobacco
North,6.47,4.03
Yorkshire,6.13,3.76
Northeast,6.19,3.77
import urllib.request
import json
import sqlite3
from key import ID, SECRET
CLIENT_ID = ID
CLIENT_SECRET = SECRET
v = '20170315'
url = 'https://api.foursquare.com/v2/venues/categories?client_id='+ CLIENT_ID +'&client_secret=' + SECRET + '&v=' + v
@broschke
broschke / pandas_to_vertica.py
Created March 26, 2018 14:09
Snippet to move Pandas dataframe to CSV then upload to Vertica
import pandas as pd
import numpy as np
import os
import pyodbc
import time
#this is a sample dataframe created for testing
df = pd.DataFrame(np.random.randint(0,100,size=(100, 4)), columns=list('ABCD'))
#create a list of the column names
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import numpy as np
import pandas as pd
import datetime
# capture current week and same week last year
date_list = []
date = datetime.datetime.now().date()
for i in range(7):
date_list.append(date - datetime.timedelta(days=i))
#!/usr/bin/env python
# coding: utf-8
import xml.etree.ElementTree as ET
import tableauserverclient as TSC
import pandas as pd
import numpy as np
import os
import shutil
from pathlib import Path