Created
December 23, 2015 21:53
-
-
Save mfinkle/40d25d107c6bddd8b03c to your computer and use it in GitHub Desktop.
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
{"nbformat_minor": 0, "cells": [{"execution_count": 5, "cell_type": "code", "source": "import datetime as dt\nimport operator\nimport pandas as pd\nimport ujson as json\n\nfrom moztelemetry import get_pings, get_pings_properties, get_one_ping_per_client\nfrom __future__ import division\n\n%pylab inline", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Populating the interactive namespace from numpy and matplotlib\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 6, "cell_type": "code", "source": "now = dt.datetime.now()\nstart = now - dt.timedelta(7)\nend = now - dt.timedelta(1)\n\npings = get_pings(sc, app=\"Fennec\", channel=\"release\",\n submission_date=(start.strftime(\"%Y%m%d\"), end.strftime(\"%Y%m%d\")),\n build_id=(\"20150901000000\", \"99999999999999\"),\n fraction=0.01)\n\nsubset = get_pings_properties(pings, [\"clientId\",\n \"application/channel\",\n \"application/version\",\n \"environment/system/os/version\",\n \"environment/system/memoryMB\"])", "outputs": [], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 7, "cell_type": "code", "source": "def transform(ping): \n channel = ping[\"application/channel\"]\n version = ping[\"application/version\"]\n \n os_version = ping[\"environment/system/os/version\"]\n \n #memory = ping[\"environment/system/memoryMB\"]\n \n return \" \".join([\"Fennec\", channel, version, str(os_version)])\n\ntransformed = get_one_ping_per_client(subset).map(transform)\ngrouped = pd.Series(transformed.countByValue())", "outputs": [], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 8, "cell_type": "code", "source": "!mkdir -p ./output\n#(100*grouped/grouped.sum()).to_csv(\"./output/distribution.csv\")\ngrouped.to_csv(\"./output/distribution.csv\")", "outputs": [], "metadata": {"collapsed": true, "trusted": true}}], "nbformat": 4, "metadata": {"kernelspec": {"display_name": "Python 2", "name": "python2", "language": "python"}, "language_info": {"mimetype": "text/x-python", "nbconvert_exporter": "python", "version": "2.7.9", "name": "python", "file_extension": ".py", "pygments_lexer": "ipython2", "codemirror_mode": {"version": 2, "name": "ipython"}}}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment