{"id":20580095,"url":"https://github.com/iyashwantsaini/911_capstone","last_synced_at":"2026-06-10T09:31:43.308Z","repository":{"id":112235277,"uuid":"287518748","full_name":"iyashwantsaini/911_capstone","owner":"iyashwantsaini","description":"For this capstone project we will be analyzing some 911 call data from Kaggle.","archived":false,"fork":false,"pushed_at":"2020-08-14T11:41:48.000Z","size":4505,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-10T00:42:25.085Z","etag":null,"topics":["capstone","data-science","data-visualization","python3"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iyashwantsaini.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-14T11:37:01.000Z","updated_at":"2020-08-14T11:43:27.000Z","dependencies_parsed_at":"2023-05-11T19:15:36.668Z","dependency_job_id":null,"html_url":"https://github.com/iyashwantsaini/911_capstone","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/iyashwantsaini/911_capstone","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iyashwantsaini%2F911_capstone","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iyashwantsaini%2F911_capstone/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iyashwantsaini%2F911_capstone/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iyashwantsaini%2F911_capstone/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iyashwantsaini","download_url":"https://codeload.github.com/iyashwantsaini/911_capstone/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iyashwantsaini%2F911_capstone/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34146871,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-10T02:00:07.152Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["capstone","data-science","data-visualization","python3"],"created_at":"2024-11-16T06:20:11.205Z","updated_at":"2026-06-10T09:31:42.591Z","avatar_url":"https://github.com/iyashwantsaini.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 911 Calls Capstone Project\n\nIn this capstone project we analyze some 911 call data from [Kaggle](https://www.kaggle.com/mchirico/montcoalert). The data contains the following fields:\n\n* lat : String variable, Latitude\n* lng: String variable, Longitude\n* desc: String variable, Description of the Emergency Call\n* zip: String variable, Zipcode\n* title: String variable, Title\n* timeStamp: String variable, YYYY-MM-DD HH:MM:SS\n* twp: String variable, Township\n* addr: String variable, Address\n* e: String variable, Dummy variable (always 1)\n\n\n## Data and Setup\n\n____\n** Import numpy and pandas **\n\n\n```python\nimport numpy as np\nimport pandas as pd\n```\n\n** Import visualization libraries and set %matplotlib inline. **\n\n\n```python\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n%matplotlib inline\n```\n\n** Read in the csv file as a dataframe called df **\n\n\n```python\ndf=pd.read_csv('911.csv')\n```\n\n** Check the info() of the df **\n\n\n```python\ndf.info()\n```\n\n    \u003cclass 'pandas.core.frame.DataFrame'\u003e\n    RangeIndex: 99492 entries, 0 to 99491\n    Data columns (total 9 columns):\n     #   Column     Non-Null Count  Dtype  \n    ---  ------     --------------  -----  \n     0   lat        99492 non-null  float64\n     1   lng        99492 non-null  float64\n     2   desc       99492 non-null  object \n     3   zip        86637 non-null  float64\n     4   title      99492 non-null  object \n     5   timeStamp  99492 non-null  object \n     6   twp        99449 non-null  object \n     7   addr       98973 non-null  object \n     8   e          99492 non-null  int64  \n    dtypes: float64(3), int64(1), object(5)\n    memory usage: 6.8+ MB\n    \n\n** Check the head of df **\n\n\n```python\ndf.head()\n```\n\n\n\n\n\u003cdiv\u003e\n\u003cstyle scoped\u003e\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n\u003c/style\u003e\n\u003ctable border=\"1\" class=\"dataframe\"\u003e\n  \u003cthead\u003e\n    \u003ctr style=\"text-align: right;\"\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003elat\u003c/th\u003e\n      \u003cth\u003elng\u003c/th\u003e\n      \u003cth\u003edesc\u003c/th\u003e\n      \u003cth\u003ezip\u003c/th\u003e\n      \u003cth\u003etitle\u003c/th\u003e\n      \u003cth\u003etimeStamp\u003c/th\u003e\n      \u003cth\u003etwp\u003c/th\u003e\n      \u003cth\u003eaddr\u003c/th\u003e\n      \u003cth\u003ee\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003cth\u003e0\u003c/th\u003e\n      \u003ctd\u003e40.297876\u003c/td\u003e\n      \u003ctd\u003e-75.581294\u003c/td\u003e\n      \u003ctd\u003eREINDEER CT \u0026amp; DEAD END;  NEW HANOVER; Station ...\u003c/td\u003e\n      \u003ctd\u003e19525.0\u003c/td\u003e\n      \u003ctd\u003eEMS: BACK PAINS/INJURY\u003c/td\u003e\n      \u003ctd\u003e2015-12-10 17:40:00\u003c/td\u003e\n      \u003ctd\u003eNEW HANOVER\u003c/td\u003e\n      \u003ctd\u003eREINDEER CT \u0026amp; DEAD END\u003c/td\u003e\n      \u003ctd\u003e1\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e1\u003c/th\u003e\n      \u003ctd\u003e40.258061\u003c/td\u003e\n      \u003ctd\u003e-75.264680\u003c/td\u003e\n      \u003ctd\u003eBRIAR PATH \u0026amp; WHITEMARSH LN;  HATFIELD TOWNSHIP...\u003c/td\u003e\n      \u003ctd\u003e19446.0\u003c/td\u003e\n      \u003ctd\u003eEMS: DIABETIC EMERGENCY\u003c/td\u003e\n      \u003ctd\u003e2015-12-10 17:40:00\u003c/td\u003e\n      \u003ctd\u003eHATFIELD TOWNSHIP\u003c/td\u003e\n      \u003ctd\u003eBRIAR PATH \u0026amp; WHITEMARSH LN\u003c/td\u003e\n      \u003ctd\u003e1\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e2\u003c/th\u003e\n      \u003ctd\u003e40.121182\u003c/td\u003e\n      \u003ctd\u003e-75.351975\u003c/td\u003e\n      \u003ctd\u003eHAWS AVE; NORRISTOWN; 2015-12-10 @ 14:39:21-St...\u003c/td\u003e\n      \u003ctd\u003e19401.0\u003c/td\u003e\n      \u003ctd\u003eFire: GAS-ODOR/LEAK\u003c/td\u003e\n      \u003ctd\u003e2015-12-10 17:40:00\u003c/td\u003e\n      \u003ctd\u003eNORRISTOWN\u003c/td\u003e\n      \u003ctd\u003eHAWS AVE\u003c/td\u003e\n      \u003ctd\u003e1\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e3\u003c/th\u003e\n      \u003ctd\u003e40.116153\u003c/td\u003e\n      \u003ctd\u003e-75.343513\u003c/td\u003e\n      \u003ctd\u003eAIRY ST \u0026amp; SWEDE ST;  NORRISTOWN; Station 308A;...\u003c/td\u003e\n      \u003ctd\u003e19401.0\u003c/td\u003e\n      \u003ctd\u003eEMS: CARDIAC EMERGENCY\u003c/td\u003e\n      \u003ctd\u003e2015-12-10 17:40:01\u003c/td\u003e\n      \u003ctd\u003eNORRISTOWN\u003c/td\u003e\n      \u003ctd\u003eAIRY ST \u0026amp; SWEDE ST\u003c/td\u003e\n      \u003ctd\u003e1\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e4\u003c/th\u003e\n      \u003ctd\u003e40.251492\u003c/td\u003e\n      \u003ctd\u003e-75.603350\u003c/td\u003e\n      \u003ctd\u003eCHERRYWOOD CT \u0026amp; DEAD END;  LOWER POTTSGROVE; S...\u003c/td\u003e\n      \u003ctd\u003eNaN\u003c/td\u003e\n      \u003ctd\u003eEMS: DIZZINESS\u003c/td\u003e\n      \u003ctd\u003e2015-12-10 17:40:01\u003c/td\u003e\n      \u003ctd\u003eLOWER POTTSGROVE\u003c/td\u003e\n      \u003ctd\u003eCHERRYWOOD CT \u0026amp; DEAD END\u003c/td\u003e\n      \u003ctd\u003e1\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\n\n\n## Basic Questions\n\n** What are the top 5 zipcodes for 911 calls? **\n\n\n```python\ndf['zip'].value_counts().head(5)\n```\n\n\n\n\n    19401.0    6979\n    19464.0    6643\n    19403.0    4854\n    19446.0    4748\n    19406.0    3174\n    Name: zip, dtype: int64\n\n\n\n** What are the top 5 townships (twp) for 911 calls? **\n\n\n```python\ndf['twp'].value_counts().head(5)\n```\n\n\n\n\n    LOWER MERION    8443\n    ABINGTON        5977\n    NORRISTOWN      5890\n    UPPER MERION    5227\n    CHELTENHAM      4575\n    Name: twp, dtype: int64\n\n\n\n** In the 'title' column, how many unique title codes are there? **\n\n\n```python\ndf['title'].nunique()\n```\n\n\n\n\n    110\n\n\n\n## Creating new features\n\n** In the titles column there are \"Reasons/Departments\" specified before the title code. These are EMS, Fire, and Traffic. Use .apply() with a custom lambda expression to create a new column called \"Reason\" that contains this string value.** \n\n**For example, if the title column value is EMS: BACK PAINS/INJURY , the Reason column value would be EMS. **\n\n\n```python\ndf['Reason']=df['title'].apply(lambda x : x.split(':')[0])\ndf.head()\n```\n\n\n\n\n\u003cdiv\u003e\n\u003cstyle scoped\u003e\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n\u003c/style\u003e\n\u003ctable border=\"1\" class=\"dataframe\"\u003e\n  \u003cthead\u003e\n    \u003ctr style=\"text-align: right;\"\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003elat\u003c/th\u003e\n      \u003cth\u003elng\u003c/th\u003e\n      \u003cth\u003edesc\u003c/th\u003e\n      \u003cth\u003ezip\u003c/th\u003e\n      \u003cth\u003etitle\u003c/th\u003e\n      \u003cth\u003etimeStamp\u003c/th\u003e\n      \u003cth\u003etwp\u003c/th\u003e\n      \u003cth\u003eaddr\u003c/th\u003e\n      \u003cth\u003ee\u003c/th\u003e\n      \u003cth\u003eReason\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003cth\u003e0\u003c/th\u003e\n      \u003ctd\u003e40.297876\u003c/td\u003e\n      \u003ctd\u003e-75.581294\u003c/td\u003e\n      \u003ctd\u003eREINDEER CT \u0026amp; DEAD END;  NEW HANOVER; Station ...\u003c/td\u003e\n      \u003ctd\u003e19525.0\u003c/td\u003e\n      \u003ctd\u003eEMS: BACK PAINS/INJURY\u003c/td\u003e\n      \u003ctd\u003e2015-12-10 17:40:00\u003c/td\u003e\n      \u003ctd\u003eNEW HANOVER\u003c/td\u003e\n      \u003ctd\u003eREINDEER CT \u0026amp; DEAD END\u003c/td\u003e\n      \u003ctd\u003e1\u003c/td\u003e\n      \u003ctd\u003eEMS\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e1\u003c/th\u003e\n      \u003ctd\u003e40.258061\u003c/td\u003e\n      \u003ctd\u003e-75.264680\u003c/td\u003e\n      \u003ctd\u003eBRIAR PATH \u0026amp; WHITEMARSH LN;  HATFIELD TOWNSHIP...\u003c/td\u003e\n      \u003ctd\u003e19446.0\u003c/td\u003e\n      \u003ctd\u003eEMS: DIABETIC EMERGENCY\u003c/td\u003e\n      \u003ctd\u003e2015-12-10 17:40:00\u003c/td\u003e\n      \u003ctd\u003eHATFIELD TOWNSHIP\u003c/td\u003e\n      \u003ctd\u003eBRIAR PATH \u0026amp; WHITEMARSH LN\u003c/td\u003e\n      \u003ctd\u003e1\u003c/td\u003e\n      \u003ctd\u003eEMS\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e2\u003c/th\u003e\n      \u003ctd\u003e40.121182\u003c/td\u003e\n      \u003ctd\u003e-75.351975\u003c/td\u003e\n      \u003ctd\u003eHAWS AVE; NORRISTOWN; 2015-12-10 @ 14:39:21-St...\u003c/td\u003e\n      \u003ctd\u003e19401.0\u003c/td\u003e\n      \u003ctd\u003eFire: GAS-ODOR/LEAK\u003c/td\u003e\n      \u003ctd\u003e2015-12-10 17:40:00\u003c/td\u003e\n      \u003ctd\u003eNORRISTOWN\u003c/td\u003e\n      \u003ctd\u003eHAWS AVE\u003c/td\u003e\n      \u003ctd\u003e1\u003c/td\u003e\n      \u003ctd\u003eFire\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e3\u003c/th\u003e\n      \u003ctd\u003e40.116153\u003c/td\u003e\n      \u003ctd\u003e-75.343513\u003c/td\u003e\n      \u003ctd\u003eAIRY ST \u0026amp; SWEDE ST;  NORRISTOWN; Station 308A;...\u003c/td\u003e\n      \u003ctd\u003e19401.0\u003c/td\u003e\n      \u003ctd\u003eEMS: CARDIAC EMERGENCY\u003c/td\u003e\n      \u003ctd\u003e2015-12-10 17:40:01\u003c/td\u003e\n      \u003ctd\u003eNORRISTOWN\u003c/td\u003e\n      \u003ctd\u003eAIRY ST \u0026amp; SWEDE ST\u003c/td\u003e\n      \u003ctd\u003e1\u003c/td\u003e\n      \u003ctd\u003eEMS\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e4\u003c/th\u003e\n      \u003ctd\u003e40.251492\u003c/td\u003e\n      \u003ctd\u003e-75.603350\u003c/td\u003e\n      \u003ctd\u003eCHERRYWOOD CT \u0026amp; DEAD END;  LOWER POTTSGROVE; S...\u003c/td\u003e\n      \u003ctd\u003eNaN\u003c/td\u003e\n      \u003ctd\u003eEMS: DIZZINESS\u003c/td\u003e\n      \u003ctd\u003e2015-12-10 17:40:01\u003c/td\u003e\n      \u003ctd\u003eLOWER POTTSGROVE\u003c/td\u003e\n      \u003ctd\u003eCHERRYWOOD CT \u0026amp; DEAD END\u003c/td\u003e\n      \u003ctd\u003e1\u003c/td\u003e\n      \u003ctd\u003eEMS\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\n\n\n** What is the most common Reason for a 911 call based off of this new column? **\n\n\n```python\ndf['Reason'].value_counts().head(3)\n```\n\n\n\n\n    EMS        48877\n    Traffic    35695\n    Fire       14920\n    Name: Reason, dtype: int64\n\n\n\n** Seaborn to create a countplot of 911 calls by Reason. **\n\n\n```python\nsns.countplot(x='Reason',data=df)\n```\n\n\n\n\n    \u003cmatplotlib.axes._subplots.AxesSubplot at 0x131a433a070\u003e\n\n\n\n\n![png](911%20Calls%20Data%20Capstone%20Project_files/911%20Calls%20Data%20Capstone%20Project_26_1.png)\n\n\n___\n** Now let us begin to focus on time information. What is the data type of the objects in the timeStamp column? **\n\n\n```python\ntype(df['timeStamp'][0])\n```\n\n\n\n\n    str\n\n\n\n** You should have seen that these timestamps are still strings. Use [pd.to_datetime](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.to_datetime.html) to convert the column from strings to DateTime objects. **\n\n\n```python\ndf['timeStamp']=pd.to_datetime(df['timeStamp'])\ntype(df['timeStamp'][0])\n```\n\n\n\n\n    pandas._libs.tslibs.timestamps.Timestamp\n\n\n\n** You can now grab specific attributes from a Datetime object by calling them. For example:**\n\n    time = df['timeStamp'].iloc[0]\n    time.hour\n\n**You can use Jupyter's tab method to explore the various attributes you can call. Now that the timestamp column are actually DateTime objects, use .apply() to create 3 new columns called Hour, Month, and Day of Week. You will create these columns based off of the timeStamp column, reference the solutions if you get stuck on this step.**\n\n\n```python\ndf['timeStamp'][0]\n```\n\n\n\n\n    Timestamp('2015-12-10 17:40:00')\n\n\n\n** Notice how the Day of Week is an integer 0-6. Use the .map() with this dictionary to map the actual string names to the day of the week: **\n\n    dmap = {0:'Mon',1:'Tue',2:'Wed',3:'Thu',4:'Fri',5:'Sat',6:'Sun'}\n\n\n```python\n#day\n\n# dmap = {0:'Mon',1:'Tue',2:'Wed',3:'Thu',4:'Fri',5:'Sat',6:'Sun'}\n# d=df['timeStamp'][0].dayofweek\n# d=dmap[d]\n# d\n\ndf['day']=df['timeStamp'].apply(lambda x : dmap[x.dayofweek])\ndf.head(2)\n```\n\n\n\n\n\u003cdiv\u003e\n\u003cstyle scoped\u003e\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n\u003c/style\u003e\n\u003ctable border=\"1\" class=\"dataframe\"\u003e\n  \u003cthead\u003e\n    \u003ctr style=\"text-align: right;\"\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003elat\u003c/th\u003e\n      \u003cth\u003elng\u003c/th\u003e\n      \u003cth\u003edesc\u003c/th\u003e\n      \u003cth\u003ezip\u003c/th\u003e\n      \u003cth\u003etitle\u003c/th\u003e\n      \u003cth\u003etimeStamp\u003c/th\u003e\n      \u003cth\u003etwp\u003c/th\u003e\n      \u003cth\u003eaddr\u003c/th\u003e\n      \u003cth\u003ee\u003c/th\u003e\n      \u003cth\u003eReason\u003c/th\u003e\n      \u003cth\u003eday\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003cth\u003e0\u003c/th\u003e\n      \u003ctd\u003e40.297876\u003c/td\u003e\n      \u003ctd\u003e-75.581294\u003c/td\u003e\n      \u003ctd\u003eREINDEER CT \u0026amp; DEAD END;  NEW HANOVER; Station ...\u003c/td\u003e\n      \u003ctd\u003e19525.0\u003c/td\u003e\n      \u003ctd\u003eEMS: BACK PAINS/INJURY\u003c/td\u003e\n      \u003ctd\u003e2015-12-10 17:40:00\u003c/td\u003e\n      \u003ctd\u003eNEW HANOVER\u003c/td\u003e\n      \u003ctd\u003eREINDEER CT \u0026amp; DEAD END\u003c/td\u003e\n      \u003ctd\u003e1\u003c/td\u003e\n      \u003ctd\u003eEMS\u003c/td\u003e\n      \u003ctd\u003eThu\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e1\u003c/th\u003e\n      \u003ctd\u003e40.258061\u003c/td\u003e\n      \u003ctd\u003e-75.264680\u003c/td\u003e\n      \u003ctd\u003eBRIAR PATH \u0026amp; WHITEMARSH LN;  HATFIELD TOWNSHIP...\u003c/td\u003e\n      \u003ctd\u003e19446.0\u003c/td\u003e\n      \u003ctd\u003eEMS: DIABETIC EMERGENCY\u003c/td\u003e\n      \u003ctd\u003e2015-12-10 17:40:00\u003c/td\u003e\n      \u003ctd\u003eHATFIELD TOWNSHIP\u003c/td\u003e\n      \u003ctd\u003eBRIAR PATH \u0026amp; WHITEMARSH LN\u003c/td\u003e\n      \u003ctd\u003e1\u003c/td\u003e\n      \u003ctd\u003eEMS\u003c/td\u003e\n      \u003ctd\u003eThu\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\n\n\n\n```python\n#month\n\n# m=df['timeStamp'][0].month\n# m\n\ndf['month']=df['timeStamp'].apply(lambda x : x.month)\ndf.head(2)\n```\n\n\n\n\n\u003cdiv\u003e\n\u003cstyle scoped\u003e\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n\u003c/style\u003e\n\u003ctable border=\"1\" class=\"dataframe\"\u003e\n  \u003cthead\u003e\n    \u003ctr style=\"text-align: right;\"\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003elat\u003c/th\u003e\n      \u003cth\u003elng\u003c/th\u003e\n      \u003cth\u003edesc\u003c/th\u003e\n      \u003cth\u003ezip\u003c/th\u003e\n      \u003cth\u003etitle\u003c/th\u003e\n      \u003cth\u003etimeStamp\u003c/th\u003e\n      \u003cth\u003etwp\u003c/th\u003e\n      \u003cth\u003eaddr\u003c/th\u003e\n      \u003cth\u003ee\u003c/th\u003e\n      \u003cth\u003eReason\u003c/th\u003e\n      \u003cth\u003eday\u003c/th\u003e\n      \u003cth\u003emonth\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003cth\u003e0\u003c/th\u003e\n      \u003ctd\u003e40.297876\u003c/td\u003e\n      \u003ctd\u003e-75.581294\u003c/td\u003e\n      \u003ctd\u003eREINDEER CT \u0026amp; DEAD END;  NEW HANOVER; Station ...\u003c/td\u003e\n      \u003ctd\u003e19525.0\u003c/td\u003e\n      \u003ctd\u003eEMS: BACK PAINS/INJURY\u003c/td\u003e\n      \u003ctd\u003e2015-12-10 17:40:00\u003c/td\u003e\n      \u003ctd\u003eNEW HANOVER\u003c/td\u003e\n      \u003ctd\u003eREINDEER CT \u0026amp; DEAD END\u003c/td\u003e\n      \u003ctd\u003e1\u003c/td\u003e\n      \u003ctd\u003eEMS\u003c/td\u003e\n      \u003ctd\u003eThu\u003c/td\u003e\n      \u003ctd\u003e12\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e1\u003c/th\u003e\n      \u003ctd\u003e40.258061\u003c/td\u003e\n      \u003ctd\u003e-75.264680\u003c/td\u003e\n      \u003ctd\u003eBRIAR PATH \u0026amp; WHITEMARSH LN;  HATFIELD TOWNSHIP...\u003c/td\u003e\n      \u003ctd\u003e19446.0\u003c/td\u003e\n      \u003ctd\u003eEMS: DIABETIC EMERGENCY\u003c/td\u003e\n      \u003ctd\u003e2015-12-10 17:40:00\u003c/td\u003e\n      \u003ctd\u003eHATFIELD TOWNSHIP\u003c/td\u003e\n      \u003ctd\u003eBRIAR PATH \u0026amp; WHITEMARSH LN\u003c/td\u003e\n      \u003ctd\u003e1\u003c/td\u003e\n      \u003ctd\u003eEMS\u003c/td\u003e\n      \u003ctd\u003eThu\u003c/td\u003e\n      \u003ctd\u003e12\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\n\n\n\n```python\n#hour\n\n# h=df['timeStamp'][0].hour\n# h\n\ndf['hour']=df['timeStamp'].apply(lambda x : x.hour)\ndf.head(2)\n```\n\n\n\n\n\u003cdiv\u003e\n\u003cstyle scoped\u003e\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n\u003c/style\u003e\n\u003ctable border=\"1\" class=\"dataframe\"\u003e\n  \u003cthead\u003e\n    \u003ctr style=\"text-align: right;\"\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003elat\u003c/th\u003e\n      \u003cth\u003elng\u003c/th\u003e\n      \u003cth\u003edesc\u003c/th\u003e\n      \u003cth\u003ezip\u003c/th\u003e\n      \u003cth\u003etitle\u003c/th\u003e\n      \u003cth\u003etimeStamp\u003c/th\u003e\n      \u003cth\u003etwp\u003c/th\u003e\n      \u003cth\u003eaddr\u003c/th\u003e\n      \u003cth\u003ee\u003c/th\u003e\n      \u003cth\u003eReason\u003c/th\u003e\n      \u003cth\u003eday\u003c/th\u003e\n      \u003cth\u003emonth\u003c/th\u003e\n      \u003cth\u003ehour\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003cth\u003e0\u003c/th\u003e\n      \u003ctd\u003e40.297876\u003c/td\u003e\n      \u003ctd\u003e-75.581294\u003c/td\u003e\n      \u003ctd\u003eREINDEER CT \u0026amp; DEAD END;  NEW HANOVER; Station ...\u003c/td\u003e\n      \u003ctd\u003e19525.0\u003c/td\u003e\n      \u003ctd\u003eEMS: BACK PAINS/INJURY\u003c/td\u003e\n      \u003ctd\u003e2015-12-10 17:40:00\u003c/td\u003e\n      \u003ctd\u003eNEW HANOVER\u003c/td\u003e\n      \u003ctd\u003eREINDEER CT \u0026amp; DEAD END\u003c/td\u003e\n      \u003ctd\u003e1\u003c/td\u003e\n      \u003ctd\u003eEMS\u003c/td\u003e\n      \u003ctd\u003eThu\u003c/td\u003e\n      \u003ctd\u003e12\u003c/td\u003e\n      \u003ctd\u003e17\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e1\u003c/th\u003e\n      \u003ctd\u003e40.258061\u003c/td\u003e\n      \u003ctd\u003e-75.264680\u003c/td\u003e\n      \u003ctd\u003eBRIAR PATH \u0026amp; WHITEMARSH LN;  HATFIELD TOWNSHIP...\u003c/td\u003e\n      \u003ctd\u003e19446.0\u003c/td\u003e\n      \u003ctd\u003eEMS: DIABETIC EMERGENCY\u003c/td\u003e\n      \u003ctd\u003e2015-12-10 17:40:00\u003c/td\u003e\n      \u003ctd\u003eHATFIELD TOWNSHIP\u003c/td\u003e\n      \u003ctd\u003eBRIAR PATH \u0026amp; WHITEMARSH LN\u003c/td\u003e\n      \u003ctd\u003e1\u003c/td\u003e\n      \u003ctd\u003eEMS\u003c/td\u003e\n      \u003ctd\u003eThu\u003c/td\u003e\n      \u003ctd\u003e12\u003c/td\u003e\n      \u003ctd\u003e17\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\n\n\n** Now use seaborn to create a countplot of the Day of Week column with the hue based off of the Reason column. **\n\n\n```python\nsns.countplot(data=df,x='day',hue='Reason')\n```\n\n\n\n\n    \u003cmatplotlib.axes._subplots.AxesSubplot at 0x131a6cbf490\u003e\n\n\n\n\n![png](911%20Calls%20Data%20Capstone%20Project_files/911%20Calls%20Data%20Capstone%20Project_38_1.png)\n\n\n**Now do the same for Month:**\n\n\n```python\nsns.countplot(data=df,x='month',hue='Reason')\n```\n\n\n\n\n    \u003cmatplotlib.axes._subplots.AxesSubplot at 0x131a1676370\u003e\n\n\n\n\n![png](911%20Calls%20Data%20Capstone%20Project_files/911%20Calls%20Data%20Capstone%20Project_40_1.png)\n\n\n**Did you notice something strange about the Plot?**\n\n_____\n\n** You should have noticed it was missing some Months, let's see if we can maybe fill in this information by plotting the information in another way, possibly a simple line plot that fills in the missing months, in order to do this, we'll need to do some work with pandas... **\n\n** Now create a gropuby object called byMonth, where you group the DataFrame by the month column and use the count() method for aggregation. Use the head() method on this returned DataFrame. **\n\n\n```python\nmonthcount=df.groupby('month').count()\n# df.head(2)\nmonthcount\n```\n\n\n\n\n\u003cdiv\u003e\n\u003cstyle scoped\u003e\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n\u003c/style\u003e\n\u003ctable border=\"1\" class=\"dataframe\"\u003e\n  \u003cthead\u003e\n    \u003ctr style=\"text-align: right;\"\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003elat\u003c/th\u003e\n      \u003cth\u003elng\u003c/th\u003e\n      \u003cth\u003edesc\u003c/th\u003e\n      \u003cth\u003ezip\u003c/th\u003e\n      \u003cth\u003etitle\u003c/th\u003e\n      \u003cth\u003etimeStamp\u003c/th\u003e\n      \u003cth\u003etwp\u003c/th\u003e\n      \u003cth\u003eaddr\u003c/th\u003e\n      \u003cth\u003ee\u003c/th\u003e\n      \u003cth\u003eReason\u003c/th\u003e\n      \u003cth\u003eday\u003c/th\u003e\n      \u003cth\u003ehour\u003c/th\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003emonth\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003cth\u003e1\u003c/th\u003e\n      \u003ctd\u003e13205\u003c/td\u003e\n      \u003ctd\u003e13205\u003c/td\u003e\n      \u003ctd\u003e13205\u003c/td\u003e\n      \u003ctd\u003e11527\u003c/td\u003e\n      \u003ctd\u003e13205\u003c/td\u003e\n      \u003ctd\u003e13205\u003c/td\u003e\n      \u003ctd\u003e13203\u003c/td\u003e\n      \u003ctd\u003e13096\u003c/td\u003e\n      \u003ctd\u003e13205\u003c/td\u003e\n      \u003ctd\u003e13205\u003c/td\u003e\n      \u003ctd\u003e13205\u003c/td\u003e\n      \u003ctd\u003e13205\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e2\u003c/th\u003e\n      \u003ctd\u003e11467\u003c/td\u003e\n      \u003ctd\u003e11467\u003c/td\u003e\n      \u003ctd\u003e11467\u003c/td\u003e\n      \u003ctd\u003e9930\u003c/td\u003e\n      \u003ctd\u003e11467\u003c/td\u003e\n      \u003ctd\u003e11467\u003c/td\u003e\n      \u003ctd\u003e11465\u003c/td\u003e\n      \u003ctd\u003e11396\u003c/td\u003e\n      \u003ctd\u003e11467\u003c/td\u003e\n      \u003ctd\u003e11467\u003c/td\u003e\n      \u003ctd\u003e11467\u003c/td\u003e\n      \u003ctd\u003e11467\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e3\u003c/th\u003e\n      \u003ctd\u003e11101\u003c/td\u003e\n      \u003ctd\u003e11101\u003c/td\u003e\n      \u003ctd\u003e11101\u003c/td\u003e\n      \u003ctd\u003e9755\u003c/td\u003e\n      \u003ctd\u003e11101\u003c/td\u003e\n      \u003ctd\u003e11101\u003c/td\u003e\n      \u003ctd\u003e11092\u003c/td\u003e\n      \u003ctd\u003e11059\u003c/td\u003e\n      \u003ctd\u003e11101\u003c/td\u003e\n      \u003ctd\u003e11101\u003c/td\u003e\n      \u003ctd\u003e11101\u003c/td\u003e\n      \u003ctd\u003e11101\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e4\u003c/th\u003e\n      \u003ctd\u003e11326\u003c/td\u003e\n      \u003ctd\u003e11326\u003c/td\u003e\n      \u003ctd\u003e11326\u003c/td\u003e\n      \u003ctd\u003e9895\u003c/td\u003e\n      \u003ctd\u003e11326\u003c/td\u003e\n      \u003ctd\u003e11326\u003c/td\u003e\n      \u003ctd\u003e11323\u003c/td\u003e\n      \u003ctd\u003e11283\u003c/td\u003e\n      \u003ctd\u003e11326\u003c/td\u003e\n      \u003ctd\u003e11326\u003c/td\u003e\n      \u003ctd\u003e11326\u003c/td\u003e\n      \u003ctd\u003e11326\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e5\u003c/th\u003e\n      \u003ctd\u003e11423\u003c/td\u003e\n      \u003ctd\u003e11423\u003c/td\u003e\n      \u003ctd\u003e11423\u003c/td\u003e\n      \u003ctd\u003e9946\u003c/td\u003e\n      \u003ctd\u003e11423\u003c/td\u003e\n      \u003ctd\u003e11423\u003c/td\u003e\n      \u003ctd\u003e11420\u003c/td\u003e\n      \u003ctd\u003e11378\u003c/td\u003e\n      \u003ctd\u003e11423\u003c/td\u003e\n      \u003ctd\u003e11423\u003c/td\u003e\n      \u003ctd\u003e11423\u003c/td\u003e\n      \u003ctd\u003e11423\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e6\u003c/th\u003e\n      \u003ctd\u003e11786\u003c/td\u003e\n      \u003ctd\u003e11786\u003c/td\u003e\n      \u003ctd\u003e11786\u003c/td\u003e\n      \u003ctd\u003e10212\u003c/td\u003e\n      \u003ctd\u003e11786\u003c/td\u003e\n      \u003ctd\u003e11786\u003c/td\u003e\n      \u003ctd\u003e11777\u003c/td\u003e\n      \u003ctd\u003e11732\u003c/td\u003e\n      \u003ctd\u003e11786\u003c/td\u003e\n      \u003ctd\u003e11786\u003c/td\u003e\n      \u003ctd\u003e11786\u003c/td\u003e\n      \u003ctd\u003e11786\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e7\u003c/th\u003e\n      \u003ctd\u003e12137\u003c/td\u003e\n      \u003ctd\u003e12137\u003c/td\u003e\n      \u003ctd\u003e12137\u003c/td\u003e\n      \u003ctd\u003e10633\u003c/td\u003e\n      \u003ctd\u003e12137\u003c/td\u003e\n      \u003ctd\u003e12137\u003c/td\u003e\n      \u003ctd\u003e12133\u003c/td\u003e\n      \u003ctd\u003e12088\u003c/td\u003e\n      \u003ctd\u003e12137\u003c/td\u003e\n      \u003ctd\u003e12137\u003c/td\u003e\n      \u003ctd\u003e12137\u003c/td\u003e\n      \u003ctd\u003e12137\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e8\u003c/th\u003e\n      \u003ctd\u003e9078\u003c/td\u003e\n      \u003ctd\u003e9078\u003c/td\u003e\n      \u003ctd\u003e9078\u003c/td\u003e\n      \u003ctd\u003e7832\u003c/td\u003e\n      \u003ctd\u003e9078\u003c/td\u003e\n      \u003ctd\u003e9078\u003c/td\u003e\n      \u003ctd\u003e9073\u003c/td\u003e\n      \u003ctd\u003e9025\u003c/td\u003e\n      \u003ctd\u003e9078\u003c/td\u003e\n      \u003ctd\u003e9078\u003c/td\u003e\n      \u003ctd\u003e9078\u003c/td\u003e\n      \u003ctd\u003e9078\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e12\u003c/th\u003e\n      \u003ctd\u003e7969\u003c/td\u003e\n      \u003ctd\u003e7969\u003c/td\u003e\n      \u003ctd\u003e7969\u003c/td\u003e\n      \u003ctd\u003e6907\u003c/td\u003e\n      \u003ctd\u003e7969\u003c/td\u003e\n      \u003ctd\u003e7969\u003c/td\u003e\n      \u003ctd\u003e7963\u003c/td\u003e\n      \u003ctd\u003e7916\u003c/td\u003e\n      \u003ctd\u003e7969\u003c/td\u003e\n      \u003ctd\u003e7969\u003c/td\u003e\n      \u003ctd\u003e7969\u003c/td\u003e\n      \u003ctd\u003e7969\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\n\n\n** Now create a simple plot off of the dataframe indicating the count of calls per month. **\n\n\n```python\nmonthcount.plot()\n```\n\n\n\n\n    \u003cmatplotlib.axes._subplots.AxesSubplot at 0x131a154cd00\u003e\n\n\n\n\n![png](911%20Calls%20Data%20Capstone%20Project_files/911%20Calls%20Data%20Capstone%20Project_45_1.png)\n\n\n** Now see if you can use seaborn's lmplot() to create a linear fit on the number of calls per month. Keep in mind you may need to reset the index to a column. **\n\n\n```python\nsns.lmplot(data=monthcount.reset_index(),x='month',y='twp')\n```\n\n\n\n\n    \u003cseaborn.axisgrid.FacetGrid at 0x131a16c9b50\u003e\n\n\n\n\n![png](911%20Calls%20Data%20Capstone%20Project_files/911%20Calls%20Data%20Capstone%20Project_47_1.png)\n\n\n**Create a new column called 'Date' that contains the date from the timeStamp column. You'll need to use apply along with the .date() method. ** \n\n\n```python\ndf['date']=df['timeStamp'].apply(lambda x : x.date())\ndf.head(2)\n```\n\n\n\n\n\u003cdiv\u003e\n\u003cstyle scoped\u003e\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n\u003c/style\u003e\n\u003ctable border=\"1\" class=\"dataframe\"\u003e\n  \u003cthead\u003e\n    \u003ctr style=\"text-align: right;\"\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003elat\u003c/th\u003e\n      \u003cth\u003elng\u003c/th\u003e\n      \u003cth\u003edesc\u003c/th\u003e\n      \u003cth\u003ezip\u003c/th\u003e\n      \u003cth\u003etitle\u003c/th\u003e\n      \u003cth\u003etimeStamp\u003c/th\u003e\n      \u003cth\u003etwp\u003c/th\u003e\n      \u003cth\u003eaddr\u003c/th\u003e\n      \u003cth\u003ee\u003c/th\u003e\n      \u003cth\u003eReason\u003c/th\u003e\n      \u003cth\u003eday\u003c/th\u003e\n      \u003cth\u003emonth\u003c/th\u003e\n      \u003cth\u003ehour\u003c/th\u003e\n      \u003cth\u003edate\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003cth\u003e0\u003c/th\u003e\n      \u003ctd\u003e40.297876\u003c/td\u003e\n      \u003ctd\u003e-75.581294\u003c/td\u003e\n      \u003ctd\u003eREINDEER CT \u0026amp; DEAD END;  NEW HANOVER; Station ...\u003c/td\u003e\n      \u003ctd\u003e19525.0\u003c/td\u003e\n      \u003ctd\u003eEMS: BACK PAINS/INJURY\u003c/td\u003e\n      \u003ctd\u003e2015-12-10 17:40:00\u003c/td\u003e\n      \u003ctd\u003eNEW HANOVER\u003c/td\u003e\n      \u003ctd\u003eREINDEER CT \u0026amp; DEAD END\u003c/td\u003e\n      \u003ctd\u003e1\u003c/td\u003e\n      \u003ctd\u003eEMS\u003c/td\u003e\n      \u003ctd\u003eThu\u003c/td\u003e\n      \u003ctd\u003e12\u003c/td\u003e\n      \u003ctd\u003e17\u003c/td\u003e\n      \u003ctd\u003e2015-12-10\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e1\u003c/th\u003e\n      \u003ctd\u003e40.258061\u003c/td\u003e\n      \u003ctd\u003e-75.264680\u003c/td\u003e\n      \u003ctd\u003eBRIAR PATH \u0026amp; WHITEMARSH LN;  HATFIELD TOWNSHIP...\u003c/td\u003e\n      \u003ctd\u003e19446.0\u003c/td\u003e\n      \u003ctd\u003eEMS: DIABETIC EMERGENCY\u003c/td\u003e\n      \u003ctd\u003e2015-12-10 17:40:00\u003c/td\u003e\n      \u003ctd\u003eHATFIELD TOWNSHIP\u003c/td\u003e\n      \u003ctd\u003eBRIAR PATH \u0026amp; WHITEMARSH LN\u003c/td\u003e\n      \u003ctd\u003e1\u003c/td\u003e\n      \u003ctd\u003eEMS\u003c/td\u003e\n      \u003ctd\u003eThu\u003c/td\u003e\n      \u003ctd\u003e12\u003c/td\u003e\n      \u003ctd\u003e17\u003c/td\u003e\n      \u003ctd\u003e2015-12-10\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\n\n\n** Now groupby this Date column with the count() aggregate and create a plot of counts of 911 calls.**\n\n\n```python\ndf.groupby('date').count().plot(figsize=(10,5))\n```\n\n\n\n\n    \u003cmatplotlib.axes._subplots.AxesSubplot at 0x131a8c3fd60\u003e\n\n\n\n\n![png](911%20Calls%20Data%20Capstone%20Project_files/911%20Calls%20Data%20Capstone%20Project_51_1.png)\n\n\n** Now recreate this plot but create 3 separate plots with each plot representing a Reason for the 911 call**\n\n\n```python\ndf[df['Reason']=='Traffic'].groupby('date').count()['twp'].plot(figsize=(10,5))\nplt.title('traffic')\n```\n\n\n\n\n    Text(0.5, 1.0, 'traffic')\n\n\n\n\n![png](911%20Calls%20Data%20Capstone%20Project_files/911%20Calls%20Data%20Capstone%20Project_53_1.png)\n\n\n\n```python\ndf[df['Reason']=='Fire'].groupby('date').count()['twp'].plot(figsize=(10,5))\nplt.title('fire')\n```\n\n\n\n\n    Text(0.5, 1.0, 'fire')\n\n\n\n\n![png](911%20Calls%20Data%20Capstone%20Project_files/911%20Calls%20Data%20Capstone%20Project_54_1.png)\n\n\n\n```python\ndf[df['Reason']=='EMS'].groupby('date').count()['twp'].plot(figsize=(10,5))\nplt.title('ems')\n```\n\n\n\n\n    Text(0.5, 1.0, 'ems')\n\n\n\n\n![png](911%20Calls%20Data%20Capstone%20Project_files/911%20Calls%20Data%20Capstone%20Project_55_1.png)\n\n\n____\n** Now let's move on to creating  heatmaps with seaborn and our data. We'll first need to restructure the dataframe so that the columns become the Hours and the Index becomes the Day of the Week. There are lots of ways to do this, but I would recommend trying to combine groupby with an [unstack](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.unstack.html) method.\n\n\n```python\ndayhour=df.groupby(by=['day','hour']).count()['Reason'].unstack()\ndayhour.head(5)\n```\n\n\n\n\n\u003cdiv\u003e\n\u003cstyle scoped\u003e\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n\u003c/style\u003e\n\u003ctable border=\"1\" class=\"dataframe\"\u003e\n  \u003cthead\u003e\n    \u003ctr style=\"text-align: right;\"\u003e\n      \u003cth\u003ehour\u003c/th\u003e\n      \u003cth\u003e0\u003c/th\u003e\n      \u003cth\u003e1\u003c/th\u003e\n      \u003cth\u003e2\u003c/th\u003e\n      \u003cth\u003e3\u003c/th\u003e\n      \u003cth\u003e4\u003c/th\u003e\n      \u003cth\u003e5\u003c/th\u003e\n      \u003cth\u003e6\u003c/th\u003e\n      \u003cth\u003e7\u003c/th\u003e\n      \u003cth\u003e8\u003c/th\u003e\n      \u003cth\u003e9\u003c/th\u003e\n      \u003cth\u003e...\u003c/th\u003e\n      \u003cth\u003e14\u003c/th\u003e\n      \u003cth\u003e15\u003c/th\u003e\n      \u003cth\u003e16\u003c/th\u003e\n      \u003cth\u003e17\u003c/th\u003e\n      \u003cth\u003e18\u003c/th\u003e\n      \u003cth\u003e19\u003c/th\u003e\n      \u003cth\u003e20\u003c/th\u003e\n      \u003cth\u003e21\u003c/th\u003e\n      \u003cth\u003e22\u003c/th\u003e\n      \u003cth\u003e23\u003c/th\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003eday\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003cth\u003eFri\u003c/th\u003e\n      \u003ctd\u003e275\u003c/td\u003e\n      \u003ctd\u003e235\u003c/td\u003e\n      \u003ctd\u003e191\u003c/td\u003e\n      \u003ctd\u003e175\u003c/td\u003e\n      \u003ctd\u003e201\u003c/td\u003e\n      \u003ctd\u003e194\u003c/td\u003e\n      \u003ctd\u003e372\u003c/td\u003e\n      \u003ctd\u003e598\u003c/td\u003e\n      \u003ctd\u003e742\u003c/td\u003e\n      \u003ctd\u003e752\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e932\u003c/td\u003e\n      \u003ctd\u003e980\u003c/td\u003e\n      \u003ctd\u003e1039\u003c/td\u003e\n      \u003ctd\u003e980\u003c/td\u003e\n      \u003ctd\u003e820\u003c/td\u003e\n      \u003ctd\u003e696\u003c/td\u003e\n      \u003ctd\u003e667\u003c/td\u003e\n      \u003ctd\u003e559\u003c/td\u003e\n      \u003ctd\u003e514\u003c/td\u003e\n      \u003ctd\u003e474\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003eMon\u003c/th\u003e\n      \u003ctd\u003e282\u003c/td\u003e\n      \u003ctd\u003e221\u003c/td\u003e\n      \u003ctd\u003e201\u003c/td\u003e\n      \u003ctd\u003e194\u003c/td\u003e\n      \u003ctd\u003e204\u003c/td\u003e\n      \u003ctd\u003e267\u003c/td\u003e\n      \u003ctd\u003e397\u003c/td\u003e\n      \u003ctd\u003e653\u003c/td\u003e\n      \u003ctd\u003e819\u003c/td\u003e\n      \u003ctd\u003e786\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e869\u003c/td\u003e\n      \u003ctd\u003e913\u003c/td\u003e\n      \u003ctd\u003e989\u003c/td\u003e\n      \u003ctd\u003e997\u003c/td\u003e\n      \u003ctd\u003e885\u003c/td\u003e\n      \u003ctd\u003e746\u003c/td\u003e\n      \u003ctd\u003e613\u003c/td\u003e\n      \u003ctd\u003e497\u003c/td\u003e\n      \u003ctd\u003e472\u003c/td\u003e\n      \u003ctd\u003e325\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003eSat\u003c/th\u003e\n      \u003ctd\u003e375\u003c/td\u003e\n      \u003ctd\u003e301\u003c/td\u003e\n      \u003ctd\u003e263\u003c/td\u003e\n      \u003ctd\u003e260\u003c/td\u003e\n      \u003ctd\u003e224\u003c/td\u003e\n      \u003ctd\u003e231\u003c/td\u003e\n      \u003ctd\u003e257\u003c/td\u003e\n      \u003ctd\u003e391\u003c/td\u003e\n      \u003ctd\u003e459\u003c/td\u003e\n      \u003ctd\u003e640\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e789\u003c/td\u003e\n      \u003ctd\u003e796\u003c/td\u003e\n      \u003ctd\u003e848\u003c/td\u003e\n      \u003ctd\u003e757\u003c/td\u003e\n      \u003ctd\u003e778\u003c/td\u003e\n      \u003ctd\u003e696\u003c/td\u003e\n      \u003ctd\u003e628\u003c/td\u003e\n      \u003ctd\u003e572\u003c/td\u003e\n      \u003ctd\u003e506\u003c/td\u003e\n      \u003ctd\u003e467\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003eSun\u003c/th\u003e\n      \u003ctd\u003e383\u003c/td\u003e\n      \u003ctd\u003e306\u003c/td\u003e\n      \u003ctd\u003e286\u003c/td\u003e\n      \u003ctd\u003e268\u003c/td\u003e\n      \u003ctd\u003e242\u003c/td\u003e\n      \u003ctd\u003e240\u003c/td\u003e\n      \u003ctd\u003e300\u003c/td\u003e\n      \u003ctd\u003e402\u003c/td\u003e\n      \u003ctd\u003e483\u003c/td\u003e\n      \u003ctd\u003e620\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e684\u003c/td\u003e\n      \u003ctd\u003e691\u003c/td\u003e\n      \u003ctd\u003e663\u003c/td\u003e\n      \u003ctd\u003e714\u003c/td\u003e\n      \u003ctd\u003e670\u003c/td\u003e\n      \u003ctd\u003e655\u003c/td\u003e\n      \u003ctd\u003e537\u003c/td\u003e\n      \u003ctd\u003e461\u003c/td\u003e\n      \u003ctd\u003e415\u003c/td\u003e\n      \u003ctd\u003e330\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003eThu\u003c/th\u003e\n      \u003ctd\u003e278\u003c/td\u003e\n      \u003ctd\u003e202\u003c/td\u003e\n      \u003ctd\u003e233\u003c/td\u003e\n      \u003ctd\u003e159\u003c/td\u003e\n      \u003ctd\u003e182\u003c/td\u003e\n      \u003ctd\u003e203\u003c/td\u003e\n      \u003ctd\u003e362\u003c/td\u003e\n      \u003ctd\u003e570\u003c/td\u003e\n      \u003ctd\u003e777\u003c/td\u003e\n      \u003ctd\u003e828\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e876\u003c/td\u003e\n      \u003ctd\u003e969\u003c/td\u003e\n      \u003ctd\u003e935\u003c/td\u003e\n      \u003ctd\u003e1013\u003c/td\u003e\n      \u003ctd\u003e810\u003c/td\u003e\n      \u003ctd\u003e698\u003c/td\u003e\n      \u003ctd\u003e617\u003c/td\u003e\n      \u003ctd\u003e553\u003c/td\u003e\n      \u003ctd\u003e424\u003c/td\u003e\n      \u003ctd\u003e354\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\u003cp\u003e5 rows × 24 columns\u003c/p\u003e\n\u003c/div\u003e\n\n\n\n** Now create a HeatMap using this new DataFrame. **\n\n\n```python\nplt.figure(figsize=(12,4))\nsns.heatmap(data=dayhour,cmap='viridis')\n```\n\n\n\n\n    \u003cmatplotlib.axes._subplots.AxesSubplot at 0x131c289d5b0\u003e\n\n\n\n\n![png](911%20Calls%20Data%20Capstone%20Project_files/911%20Calls%20Data%20Capstone%20Project_59_1.png)\n\n\n** Now create a clustermap using this DataFrame. **\n\n\n```python\nsns.clustermap(data=dayhour,cmap='viridis')\n```\n\n\n\n\n    \u003cseaborn.matrix.ClusterGrid at 0x131c480e370\u003e\n\n\n\n\n![png](911%20Calls%20Data%20Capstone%20Project_files/911%20Calls%20Data%20Capstone%20Project_61_1.png)\n\n\n** Repeating same plots and operations, for a DataFrame that shows the Month as the column. **\n\n\n```python\ndaymonth=df.groupby(by=['day','month']).count()['Reason'].unstack()\ndaymonth.head(5)\n```\n\n\n\n\n\u003cdiv\u003e\n\u003cstyle scoped\u003e\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n\u003c/style\u003e\n\u003ctable border=\"1\" class=\"dataframe\"\u003e\n  \u003cthead\u003e\n    \u003ctr style=\"text-align: right;\"\u003e\n      \u003cth\u003emonth\u003c/th\u003e\n      \u003cth\u003e1\u003c/th\u003e\n      \u003cth\u003e2\u003c/th\u003e\n      \u003cth\u003e3\u003c/th\u003e\n      \u003cth\u003e4\u003c/th\u003e\n      \u003cth\u003e5\u003c/th\u003e\n      \u003cth\u003e6\u003c/th\u003e\n      \u003cth\u003e7\u003c/th\u003e\n      \u003cth\u003e8\u003c/th\u003e\n      \u003cth\u003e12\u003c/th\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003eday\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003cth\u003eFri\u003c/th\u003e\n      \u003ctd\u003e1970\u003c/td\u003e\n      \u003ctd\u003e1581\u003c/td\u003e\n      \u003ctd\u003e1525\u003c/td\u003e\n      \u003ctd\u003e1958\u003c/td\u003e\n      \u003ctd\u003e1730\u003c/td\u003e\n      \u003ctd\u003e1649\u003c/td\u003e\n      \u003ctd\u003e2045\u003c/td\u003e\n      \u003ctd\u003e1310\u003c/td\u003e\n      \u003ctd\u003e1065\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003eMon\u003c/th\u003e\n      \u003ctd\u003e1727\u003c/td\u003e\n      \u003ctd\u003e1964\u003c/td\u003e\n      \u003ctd\u003e1535\u003c/td\u003e\n      \u003ctd\u003e1598\u003c/td\u003e\n      \u003ctd\u003e1779\u003c/td\u003e\n      \u003ctd\u003e1617\u003c/td\u003e\n      \u003ctd\u003e1692\u003c/td\u003e\n      \u003ctd\u003e1511\u003c/td\u003e\n      \u003ctd\u003e1257\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003eSat\u003c/th\u003e\n      \u003ctd\u003e2291\u003c/td\u003e\n      \u003ctd\u003e1441\u003c/td\u003e\n      \u003ctd\u003e1266\u003c/td\u003e\n      \u003ctd\u003e1734\u003c/td\u003e\n      \u003ctd\u003e1444\u003c/td\u003e\n      \u003ctd\u003e1388\u003c/td\u003e\n      \u003ctd\u003e1695\u003c/td\u003e\n      \u003ctd\u003e1099\u003c/td\u003e\n      \u003ctd\u003e978\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003eSun\u003c/th\u003e\n      \u003ctd\u003e1960\u003c/td\u003e\n      \u003ctd\u003e1229\u003c/td\u003e\n      \u003ctd\u003e1102\u003c/td\u003e\n      \u003ctd\u003e1488\u003c/td\u003e\n      \u003ctd\u003e1424\u003c/td\u003e\n      \u003ctd\u003e1333\u003c/td\u003e\n      \u003ctd\u003e1672\u003c/td\u003e\n      \u003ctd\u003e1021\u003c/td\u003e\n      \u003ctd\u003e907\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003eThu\u003c/th\u003e\n      \u003ctd\u003e1584\u003c/td\u003e\n      \u003ctd\u003e1596\u003c/td\u003e\n      \u003ctd\u003e1900\u003c/td\u003e\n      \u003ctd\u003e1601\u003c/td\u003e\n      \u003ctd\u003e1590\u003c/td\u003e\n      \u003ctd\u003e2065\u003c/td\u003e\n      \u003ctd\u003e1646\u003c/td\u003e\n      \u003ctd\u003e1230\u003c/td\u003e\n      \u003ctd\u003e1266\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\n\n\n\n```python\nplt.figure(figsize=(10,4))\nsns.heatmap(data=daymonth,cmap='viridis')\n```\n\n\n\n\n    \u003cmatplotlib.axes._subplots.AxesSubplot at 0x131c4f45970\u003e\n\n\n\n\n![png](911%20Calls%20Data%20Capstone%20Project_files/911%20Calls%20Data%20Capstone%20Project_64_1.png)\n\n\n\n```python\nsns.clustermap(data=daymonth,cmap='viridis')\n```\n\n\n\n\n    \u003cseaborn.matrix.ClusterGrid at 0x131c52a5f10\u003e\n\n\n\n\n![png](911%20Calls%20Data%20Capstone%20Project_files/911%20Calls%20Data%20Capstone%20Project_65_1.png)\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiyashwantsaini%2F911_capstone","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiyashwantsaini%2F911_capstone","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiyashwantsaini%2F911_capstone/lists"}