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
SELECT | |
*, | |
row_number () over () AS Row_N | |
FROM Summer_Medals | |
ORDER BY Row_N ASC; | |
-------------------- | |
SELECT | |
Year, | |
row_number() over() AS Row_N |
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
import copy | |
import random | |
# Consider using the modules imported above. | |
class Hat: | |
def __init__(self, **kwargs): | |
self.d = kwargs | |
self.contents = [ | |
key for key, val in kwargs.items() for num in range(val) | |
] |
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
# Within a Jupyter Notebook | |
import sys | |
sys.path.append("C:/somewhere/else/not/in/the/tree/of/this/jpfile") | |
# Now we can import Windows directories as packages, and refer to Python files within them | |
# the folder jpyfile need not have an __init__.py file in it | |
# folders that we import from within jpfile should | |
from folder_w_in_jpfile import my_modular_code | |
# folder_w_in_jpfile contains an __init__.py file whihc can be empty | |
# my_modular_code is a file my_modular_code.py with any other Python code you've written. | |
# This snippet is for when there are issues with |
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
-- Query to breakout events into legacy segmentation | |
CREATE TEMPORARY FUNCTION rank AS 'ABCxyz.QWERTY.hadoop.hive.udf.Rank'; | |
SET mapred.map.output.compression.codec = ABCxyz.hadoop.compression.lzo.LzopCodec; | |
SET hive.cli.print.header = TRUE; | |
SET mapred.job.priority = HIGH; | |
SET partnerid = 1731; | |
SET golivedate = "2014-03-01"; | |
-- abandondate is 15 days before golivedate |
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
SELECT | |
day, | |
clicks, | |
SUM(clicks) OVER (order by day range between '7 days' preceding and current row) accumulated_clicks | |
FROM | |
datamart.fact_network_stats_daily | |
WHERE | |
network_id = 72 | |
AND affiliate_country_code = 'FR' | |
AND banner_currency_id = 1 |
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
WITH | |
revenue_by_client | |
AS | |
( | |
SELECT | |
f.day, | |
c.client_country_name, | |
c.client_name, | |
SUM(f.revenue * er.rate) revenue_euro | |
FROM |
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
# Editing to be able to split all files in a directory | |
import sys | |
import os # for getting the list of all files in the directory, when we use batch mode | |
import re # to find file matching a particular handle/pattern | |
a = sys.argv[0] | |
print '\n', sys.argv | |
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
{ | |
"hits": { | |
"hits": [], | |
"total": 123928, | |
"max_score": 0.0 | |
}, | |
"_shards": { | |
"successful": 20, | |
"failed": 0, | |
"total": 20 |
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
{ "size": 0, | |
"query": { | |
"term": {"propertyId":"{{property_id}}"} | |
}, | |
"aggs" : { | |
"zero_or_not": { | |
"range" : { | |
"field" : "totalRoomRateInPropertyCurrency", | |
"ranges" : [ | |
{"from": 0, "to" : 0.1 }, |
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
{ "size": 0, | |
"query": { | |
"term": {"propertyId":"{{property_id}}"} | |
}, | |
"aggs": { | |
"pms_status_code": { | |
"terms" : { "field" : "confirmationStatus"}, | |
"aggs": { | |
"conf_status": { | |
"terms" : { "field" : "statusCode"}, |
NewerOlder