Skip to content

Instantly share code, notes, and snippets.

@tanpengshi
Created September 7, 2020 15:01
Show Gist options
  • Save tanpengshi/db7627152580e64dc8751d371c4d130f to your computer and use it in GitHub Desktop.
Save tanpengshi/db7627152580e64dc8751d371c4d130f to your computer and use it in GitHub Desktop.
Unique Turnstile Analysis
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"UNIT SCP \n",
"R001 00-00-00 1\n",
"R273 00-00-01 1\n",
" 00-00-00 1\n",
"R272 01-06-02 1\n",
" 01-06-01 1\n",
" ..\n",
"R112 01-06-01 1\n",
" 01-06-00 1\n",
" 01-05-01 1\n",
"R113 00-00-04 1\n",
"R572 01-03-04 1\n",
"Name: STATION, Length: 4945, dtype: int64"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.groupby(['UNIT','SCP'])['STATION'].nunique().sort_values() \n",
"#checking combination of 'UNIT' and 'SCP' is unique to each station,implying each combination refers to a unique turnstile"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment