Created
July 20, 2017 03:09
-
-
Save saptarshiguha/daab103e3630724321c1fba74539d512 to your computer and use it in GitHub Desktop.
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 | |
import random | |
import subprocess | |
import time | |
import pandas as pd | |
useALL = False | |
ms = sqlContext.read.load("s3://telemetry-parquet/main_summary/v4", "parquet",mergeSchema=True) | |
ms2 = ms.select("sample_id","client_id","submission_date_s3","country","subsession_start_date") | |
if useALL: | |
ms3 = ms2.filter("app_name='Firefox'") | |
FAC=1.0 | |
else: | |
random.seed(10) | |
sampleids = [ random.randint(1,100) for x in range(10)] | |
samplechar = [ "'{}'".format(str(x)) for x in sampleids] | |
FAC=100.0/float(len(sampleids)) | |
ms3 = ms2.filter("app_name='Firefox' and sample_id in ({})".format( ",".join(samplechar))) | |
sqlContext.registerDataFrameAsTable(ms3, "ms3") | |
ms4 = sqlContext.sql(""" | |
select | |
client_id, | |
submission_date_s3 as submissiondate, | |
substring(subsession_start_date,1,10) as activitydate, | |
case when country in ('US','DE','BR','FR','IN','ID','RU','PL','IT','GB','ES','CN','CA','JP','MX') then country | |
else 'others' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment