In [2]:
import math
from pandas import DataFrame, read_csv
In [3]:
def distance(xa, ya, xb, yb):
    return math.sqrt( math.pow(xb-xa, 2) + math.pow(yb-ya, 2) )
In [4]:
df = read_csv( 'data-coords.csv', header=None, names=['user', 'xa', 'ya', 'xb', 'yb'] )
In [5]:
df.head()
Out[5]:
user xa ya xb yb
0 karenalma 82 316 904 406
1 eurello 149 299 811 411
2 beckett 211 340 1024 338
3 erica 289 314 962 340
4 rebecca 331 345 1023 398

5 rows × 5 columns

In [6]:
df['xa'] = df['xa'].astype(int)
df['ya'] = df['ya'].astype(int)
df['xb'] = df['xb'].astype(int)
df['yb'] = df['yb'].astype(int)
In [7]:
df['d'] = map( distance, df['xa'], df['ya'], df['xb'], df['yb'] )
In [8]:
df['d'].median()
Out[8]:
278.84224930953343
In [9]:
sd = df.sort(['d'])

Top Stationary People

In [10]:
sd.head()
Out[10]:
user xa ya xb yb d
81 paul 1040 435 1022 448 22.203603
34 philip 397 587 420 594 24.041631
30 paulm 535 404 572 414 38.327536
13 martinremy 155 556 198 549 43.566042
17 chrisrudzki 303 565 344 590 48.020829

5 rows × 6 columns

Top People who Move

In [11]:
sd.tail()
Out[11]:
user xa ya xb yb d
0 karenalma 82 316 904 406 826.912329
80 matthusby 1179 418 352 551 837.626408
5 westi 289 377 1140 419 852.035797
75 nikolay 951 597 117 374 863.298905
88 kevinconboy 917 409 46 389 871.229591

5 rows × 6 columns

Calculate X-Axis Change

In [12]:
df['z'] = 0
In [13]:
df['dx'] = map( distance, df['xa'], df['z'], df['xb'], df['z'] )
In [15]:
df['dx'].median()
Out[15]:
269.0
In [16]:
simulation = 384.0
In [17]:
100 * (simulation - Out[14])/simulation
Out[17]:
18.551187275985665
In [18]:
sd['d'].plot(kind='bar')
Out[18]:
<matplotlib.axes.AxesSubplot at 0x109d8d450>