import ujson as json
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import plotly.plotly as py
from moztelemetry import get_pings, get_pings_properties, get_one_ping_per_client, get_clients_history
%pylab inline
Populating the interactive namespace from numpy and matplotlib
pings = get_pings(sc, app="Firefox", channel="nightly", submission_date="20150610", fraction=1, schema="v4")
def extract_count_histograms(ping):
for histogram_name, histogram in ping["payload"]["histograms"].iteritems():
if histogram["histogram_type"] == 4 and histogram["values"]:
yield (histogram_name, histogram["values"]["0"])
for histogram_name, value in ping["payload"]["keyedHistograms"].iteritems():
for label, histogram in value.iteritems():
if histogram["histogram_type"] == 4 and histogram["values"]:
yield (histogram_name, histogram["values"]["0"])
histograms = pings.flatMap(extract_count_histograms).groupByKey().map(lambda x: (x[0], list(x[1]))).collect()
for histogram in histograms:
pd.Series(histogram[1]).plot(kind="hist", bins=50)
plt.xlabel(histogram[0])
plt.show()