This file contains 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
my_list = [1, 2, 3, 4, 5] | |
my_sum = 0 | |
for num in my_list: | |
my_sum += num | |
print(my_sum) |
This file contains 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
GOALE: Get sum of taxes by dept | |
# employees by dept: | |
ebd = { | |
'deli': ['mere', 'leo'], | |
'produce': ['greg'] | |
} | |
# taxes by employee: | |
tbe = { |
This file contains 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
GOALE: Get sum of taxes by dept | |
# employees by dept: | |
ebd = { | |
'deli': ['mere', 'leo'], | |
'produce': ['greg'] | |
} | |
# taxes by employee: | |
tbe = { |
This file contains 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
''' | |
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. |
This file contains 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
-- 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 |
This file contains 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
def extract_dept(col): | |
try: | |
return col.split('-')[-1] | |
except: | |
return col |
This file contains 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
# 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 |
This file contains 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
ufo [ \ | |
((ufo['Colors Reported'] == 'RED') | (ufo['Colors Reported'] == 'YELLOW')) & \ | |
((ufo['Shape Reported'] == 'FIREBALL') | (ufo['Shape Reported'] == 'EGG')) \ | |
][['City', 'Colors Reported', 'Shape Reported', 'State']] |
This file contains 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
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 |
This file contains 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
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 | |
}, |