{"cells":[
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport matplotlib.pyplot as plt\n\ndf_train = pd.read_csv(\"../input/train.csv\")"
 },
 {
  "cell_type": "markdown",
  "metadata": {},
  "source": "# The centroid of a collection of points is just the componentwise mean\n\nGiven a collection of points `{(x1,y1),...,(xn,yn)}`, the mean is just the pair `(1/n)*(∑i xi, ∑i yi)`\n\nWe can do this with a dataframe by selecting the `x`, `y`, and `place_id` columns,\ngrouping by the `place_id` and then calling `mean()` on the result."
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "df_train[[\"x\",\"y\",\"place_id\"]].groupby(\"place_id\").mean()"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": ""
 }
],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"}}, "nbformat": 4, "nbformat_minor": 0}