Skip to content

Instantly share code, notes, and snippets.

View ggodreau's full-sized avatar
🛴
don't FB my GH

Gregory Godreau ggodreau

🛴
don't FB my GH
View GitHub Profile
my_list = [1, 2, 3, 4, 5]
my_sum = 0
for num in my_list:
my_sum += num
print(my_sum)
GOALE: Get sum of taxes by dept
# employees by dept:
ebd = {
'deli': ['mere', 'leo'],
'produce': ['greg']
}
# taxes by employee:
tbe = {
GOALE: Get sum of taxes by dept
# employees by dept:
ebd = {
'deli': ['mere', 'leo'],
'produce': ['greg']
}
# taxes by employee:
tbe = {
@ggodreau
ggodreau / get_fractional_month.py
Last active November 28, 2019 15:44
Get float value distribution of months
'''
Create a function get_fractional_month
that accepts a dictionary as an argument
and returns a dictionary. The returned
dictionary should have the same keys as
the input, and the values of those keys
should be the proportion of the
individual values to the sum of ALL the
values across ALL the keys in the input
dictionary.
-- s.v.p. return the sum (gross) of sales ($) by category name! Use the 'total' col from sales
SELECT
p.category_name
,SUM(s.total)::money
FROM
sales s
LEFT JOIN
products p on p.item_no = s.item
GROUP BY 1
ORDER BY 2 DESC
def extract_dept(col):
try:
return col.split('-')[-1]
except:
return col
@ggodreau
ggodreau / hc.py
Last active November 14, 2019 16:12
# verbal q's:
# ssh'd into a machine, how would you kill all python processes?
# if you had a very large text file that was processed line by line, how could you speed up that process?
# what is the use of the heap in python?
# coding q's:
# return the highest day of the month on a per ticker,
# per month basis
# solution refs:
# https://stackoverflow.com/questions/3800551/select-first-row-in-each-group-by-group
ufo [ \
((ufo['Colors Reported'] == 'RED') | (ufo['Colors Reported'] == 'YELLOW')) & \
((ufo['Shape Reported'] == 'FIREBALL') | (ufo['Shape Reported'] == 'EGG')) \
][['City', 'Colors Reported', 'Shape Reported', 'State']]
@ggodreau
ggodreau / product.sql
Last active July 16, 2019 17:47
product.sql
CREATE TABLE product(
ProductID INTEGER NOT NULL PRIMARY KEY
,Name VARCHAR(32) NOT NULL
,ProductNumber VARCHAR(10) NOT NULL
,MakeFlag BIT NOT NULL
,FinishedGoodsFlag BIT NOT NULL
,Color VARCHAR(12)
,SafetyStockLevel INTEGER NOT NULL
,ReorderPoint INTEGER NOT NULL
,StandardCost NUMERIC(9,4) NOT NULL
store_db = {
1 : {
"store_name": "Whore Foods",
"store_address": "123 William Canon",
"store_zip": 78749,
"item_1" : {
"veg_name": "carrot",
"veg_plu": 4568,
"veg_qty": 25
},