{ "metadata": { "name": "", "signature": "sha256:7c011ce3c1df815d663b03a13ea2e0263f9ded07fdd55c462758207ce4b87564" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Map Your Google Location History\n", "\n", "- **Author:** [Chris Albon](http://www.chrisalbon.com/), [@ChrisAlbon](https://twitter.com/chrisalbon)\n", "- **Date:** -\n", "- **Repo:** [Python 3 code snippets for data science](https://github.com/chrisalbon/code_py)\n", "- **Note:**" ] }, { "cell_type": "code", "collapsed": false, "input": [ "## Step 1: Download your Google Location History\n", "\n", "Google makes this process very easy. Go here to [download your location history data](https://www.google.com/settings/takeout) and unzip it." ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Step 2: Run this script" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Preliminaries" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# Import pandas\n", "import pandas as pd\n", "\n", "# Import matplotlib and Basemap\n", "import matplotlib.pyplot as plt\n", "from mpl_toolkits.basemap import Basemap\n", "\n", "# Import decimal\n", "import decimal\n", "\n", "# Set iPython to display visualization inline\n", "%matplotlib inline" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 1 }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Read in the location history json\n", "\n", "Simply change the string to point to where you unzipped your location history json file" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# Create a dataframe from the json file in the filepath\n", "raw = pd.io.json.read_json('/Users/chrisralbon/Downloads/Location History/LocationHistory.json')" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 2 }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Let's take a look at some of the data" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# View the last five rows of the dataframe\n", "raw.tail()" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "
\n", " | locations | \n", "somePointsTruncated | \n", "
---|---|---|
369608 | \n", "{'longitudeE7': -770434474, 'timestampMs': '13... | \n", "True | \n", "
369609 | \n", "{'longitudeE7': -770433938, 'timestampMs': '13... | \n", "True | \n", "
369610 | \n", "{'longitudeE7': -770432626, 'timestampMs': '13... | \n", "True | \n", "
369611 | \n", "{'longitudeE7': -770432626, 'timestampMs': '13... | \n", "True | \n", "
369612 | \n", "{'longitudeE7': -769333633, 'timestampMs': '13... | \n", "True | \n", "