{
"cells": [
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [],
"source": [
"# The usual preamble\n",
"%matplotlib inline\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# Make the graphs a bit prettier, and bigger\n",
"plt.style.use('ggplot')\n",
"\n",
"# This is necessary to show lots of columns in pandas 0.12. \n",
"# Not necessary in pandas 0.13.\n",
"pd.set_option('display.width', 5000) \n",
"pd.set_option('display.max_columns', 60)\n",
"\n",
"plt.rcParams['figure.figsize'] = (15, 5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We're going to use a new dataset here, to demonstrate how to deal with larger datasets. This is a subset of the of 311 service requests from [NYC Open Data](https://nycopendata.socrata.com/Social-Services/311-Service-Requests-from-2010-to-Present/erm2-nwe9). "
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [],
"source": [
"# because of mixed types we specify dtype to prevent any errors\n",
"complaints = pd.read_csv('../data/311-service-requests.csv', dtype='unicode')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Depending on your pandas version, you might see an error like \"DtypeWarning: Columns (8) have mixed types\". This means that it's encountered a problem reading in our data. In this case it almost certainly means that it has columns where some of the entries are strings and some are integers.\n",
"\n",
"For now we're going to ignore it and hope we don't run into a problem, but in the long run we'd need to investigate this warning."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 2.1 What's even in it? (the summary)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"When you print a large dataframe, it will only show you the first few rows.\n",
"\n",
"If you don't see this, don't panic! The default behavior for large dataframes changed between pandas 0.12 and 0.13. Previous to 0.13 it would show you a summary of the dataframe. This includes all the columns, and how many non-null values there are in each column."
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
"
\n",
"
\n",
"
Unique Key
\n",
"
Created Date
\n",
"
Closed Date
\n",
"
Agency
\n",
"
Agency Name
\n",
"
Complaint Type
\n",
"
Descriptor
\n",
"
Location Type
\n",
"
Incident Zip
\n",
"
Incident Address
\n",
"
Street Name
\n",
"
Cross Street 1
\n",
"
Cross Street 2
\n",
"
Intersection Street 1
\n",
"
Intersection Street 2
\n",
"
Address Type
\n",
"
City
\n",
"
Landmark
\n",
"
Facility Type
\n",
"
Status
\n",
"
Due Date
\n",
"
Resolution Action Updated Date
\n",
"
Community Board
\n",
"
Borough
\n",
"
X Coordinate (State Plane)
\n",
"
Y Coordinate (State Plane)
\n",
"
Park Facility Name
\n",
"
Park Borough
\n",
"
School Name
\n",
"
School Number
\n",
"
School Region
\n",
"
School Code
\n",
"
School Phone Number
\n",
"
School Address
\n",
"
School City
\n",
"
School State
\n",
"
School Zip
\n",
"
School Not Found
\n",
"
School or Citywide Complaint
\n",
"
Vehicle Type
\n",
"
Taxi Company Borough
\n",
"
Taxi Pick Up Location
\n",
"
Bridge Highway Name
\n",
"
Bridge Highway Direction
\n",
"
Road Ramp
\n",
"
Bridge Highway Segment
\n",
"
Garage Lot Name
\n",
"
Ferry Direction
\n",
"
Ferry Terminal Name
\n",
"
Latitude
\n",
"
Longitude
\n",
"
Location
\n",
"
\n",
" \n",
" \n",
"
\n",
"
0
\n",
"
26589651
\n",
"
10/31/2013 02:08:41 AM
\n",
"
NaN
\n",
"
NYPD
\n",
"
New York City Police Department
\n",
"
Noise - Street/Sidewalk
\n",
"
Loud Talking
\n",
"
Street/Sidewalk
\n",
"
11432
\n",
"
90-03 169 STREET
\n",
"
169 STREET
\n",
"
90 AVENUE
\n",
"
91 AVENUE
\n",
"
NaN
\n",
"
NaN
\n",
"
ADDRESS
\n",
"
JAMAICA
\n",
"
NaN
\n",
"
Precinct
\n",
"
Assigned
\n",
"
10/31/2013 10:08:41 AM
\n",
"
10/31/2013 02:35:17 AM
\n",
"
12 QUEENS
\n",
"
QUEENS
\n",
"
1042027.0
\n",
"
197389.0
\n",
"
Unspecified
\n",
"
QUEENS
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
N
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
40.708275
\n",
"
-73.791604
\n",
"
(40.70827532593202, -73.79160395779721)
\n",
"
\n",
"
\n",
"
1
\n",
"
26593698
\n",
"
10/31/2013 02:01:04 AM
\n",
"
NaN
\n",
"
NYPD
\n",
"
New York City Police Department
\n",
"
Illegal Parking
\n",
"
Commercial Overnight Parking
\n",
"
Street/Sidewalk
\n",
"
11378
\n",
"
58 AVENUE
\n",
"
58 AVENUE
\n",
"
58 PLACE
\n",
"
59 STREET
\n",
"
NaN
\n",
"
NaN
\n",
"
BLOCKFACE
\n",
"
MASPETH
\n",
"
NaN
\n",
"
Precinct
\n",
"
Open
\n",
"
10/31/2013 10:01:04 AM
\n",
"
NaN
\n",
"
05 QUEENS
\n",
"
QUEENS
\n",
"
1009349.0
\n",
"
201984.0
\n",
"
Unspecified
\n",
"
QUEENS
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
N
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
40.721041
\n",
"
-73.909453
\n",
"
(40.721040535628305, -73.90945306791765)
\n",
"
\n",
"
\n",
"
2
\n",
"
26594139
\n",
"
10/31/2013 02:00:24 AM
\n",
"
10/31/2013 02:40:32 AM
\n",
"
NYPD
\n",
"
New York City Police Department
\n",
"
Noise - Commercial
\n",
"
Loud Music/Party
\n",
"
Club/Bar/Restaurant
\n",
"
10032
\n",
"
4060 BROADWAY
\n",
"
BROADWAY
\n",
"
WEST 171 STREET
\n",
"
WEST 172 STREET
\n",
"
NaN
\n",
"
NaN
\n",
"
ADDRESS
\n",
"
NEW YORK
\n",
"
NaN
\n",
"
Precinct
\n",
"
Closed
\n",
"
10/31/2013 10:00:24 AM
\n",
"
10/31/2013 02:39:42 AM
\n",
"
12 MANHATTAN
\n",
"
MANHATTAN
\n",
"
1001088.0
\n",
"
246531.0
\n",
"
Unspecified
\n",
"
MANHATTAN
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
N
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
40.843330
\n",
"
-73.939144
\n",
"
(40.84332975466513, -73.93914371913482)
\n",
"
\n",
"
\n",
"
3
\n",
"
26595721
\n",
"
10/31/2013 01:56:23 AM
\n",
"
10/31/2013 02:21:48 AM
\n",
"
NYPD
\n",
"
New York City Police Department
\n",
"
Noise - Vehicle
\n",
"
Car/Truck Horn
\n",
"
Street/Sidewalk
\n",
"
10023
\n",
"
WEST 72 STREET
\n",
"
WEST 72 STREET
\n",
"
COLUMBUS AVENUE
\n",
"
AMSTERDAM AVENUE
\n",
"
NaN
\n",
"
NaN
\n",
"
BLOCKFACE
\n",
"
NEW YORK
\n",
"
NaN
\n",
"
Precinct
\n",
"
Closed
\n",
"
10/31/2013 09:56:23 AM
\n",
"
10/31/2013 02:21:10 AM
\n",
"
07 MANHATTAN
\n",
"
MANHATTAN
\n",
"
989730.0
\n",
"
222727.0
\n",
"
Unspecified
\n",
"
MANHATTAN
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
N
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
40.778009
\n",
"
-73.980213
\n",
"
(40.7780087446372, -73.98021349023975)
\n",
"
\n",
"
\n",
"
4
\n",
"
26590930
\n",
"
10/31/2013 01:53:44 AM
\n",
"
NaN
\n",
"
DOHMH
\n",
"
Department of Health and Mental Hygiene
\n",
"
Rodent
\n",
"
Condition Attracting Rodents
\n",
"
Vacant Lot
\n",
"
10027
\n",
"
WEST 124 STREET
\n",
"
WEST 124 STREET
\n",
"
LENOX AVENUE
\n",
"
ADAM CLAYTON POWELL JR BOULEVARD
\n",
"
NaN
\n",
"
NaN
\n",
"
BLOCKFACE
\n",
"
NEW YORK
\n",
"
NaN
\n",
"
NaN
\n",
"
Pending
\n",
"
11/30/2013 01:53:44 AM
\n",
"
10/31/2013 01:59:54 AM
\n",
"
10 MANHATTAN
\n",
"
MANHATTAN
\n",
"
998815.0
\n",
"
233545.0
\n",
"
Unspecified
\n",
"
MANHATTAN
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
N
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
40.807691
\n",
"
-73.947387
\n",
"
(40.80769092704951, -73.94738703491433)
\n",
"
\n",
"
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
\n",
"
\n",
"
111064
\n",
"
26426013
\n",
"
10/04/2013 12:01:13 AM
\n",
"
10/07/2013 04:07:16 PM
\n",
"
DPR
\n",
"
Department of Parks and Recreation
\n",
"
Maintenance or Facility
\n",
"
Structure - Outdoors
\n",
"
Park
\n",
"
11213
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
BROOKLYN
\n",
"
NaN
\n",
"
NaN
\n",
"
Closed
\n",
"
10/18/2013 12:01:13 AM
\n",
"
10/07/2013 04:07:16 PM
\n",
"
08 BROOKLYN
\n",
"
BROOKLYN
\n",
"
NaN
\n",
"
NaN
\n",
"
Brower Park
\n",
"
BROOKLYN
\n",
"
Brower Park
\n",
"
B012
\n",
"
NaN
\n",
"
NaN
\n",
"
7189658900
\n",
"
Brooklyn, St. Marks, Kingston Avenues, Park Place
\n",
"
BROOKLYN
\n",
"
NY
\n",
"
11213
\n",
"
N
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
\n",
"
\n",
"
111065
\n",
"
26428083
\n",
"
10/04/2013 12:01:05 AM
\n",
"
10/04/2013 02:13:50 AM
\n",
"
NYPD
\n",
"
New York City Police Department
\n",
"
Illegal Parking
\n",
"
Posted Parking Sign Violation
\n",
"
Street/Sidewalk
\n",
"
11434
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
GUY R BREWER BOULEVARD
\n",
"
ROCKAWAY BOULEVARD
\n",
"
INTERSECTION
\n",
"
JAMAICA
\n",
"
NaN
\n",
"
Precinct
\n",
"
Closed
\n",
"
10/04/2013 08:01:05 AM
\n",
"
10/04/2013 02:13:50 AM
\n",
"
13 QUEENS
\n",
"
QUEENS
\n",
"
1048801.0
\n",
"
178419.0
\n",
"
Unspecified
\n",
"
QUEENS
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
N
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
40.656160
\n",
"
-73.767353
\n",
"
(40.656160351546845, -73.76735262738222)
\n",
"
\n",
"
\n",
"
111066
\n",
"
26428987
\n",
"
10/04/2013 12:00:45 AM
\n",
"
10/04/2013 01:25:01 AM
\n",
"
NYPD
\n",
"
New York City Police Department
\n",
"
Noise - Street/Sidewalk
\n",
"
Loud Talking
\n",
"
Street/Sidewalk
\n",
"
10016
\n",
"
344 EAST 28 STREET
\n",
"
EAST 28 STREET
\n",
"
MOUNT CARMEL PLACE
\n",
"
1 AVENUE
\n",
"
NaN
\n",
"
NaN
\n",
"
ADDRESS
\n",
"
NEW YORK
\n",
"
NaN
\n",
"
Precinct
\n",
"
Closed
\n",
"
10/04/2013 08:00:45 AM
\n",
"
10/04/2013 01:25:01 AM
\n",
"
06 MANHATTAN
\n",
"
MANHATTAN
\n",
"
990637.0
\n",
"
208987.0
\n",
"
Unspecified
\n",
"
MANHATTAN
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
N
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
40.740295
\n",
"
-73.976952
\n",
"
(40.740295354643706, -73.97695165980414)
\n",
"
\n",
"
\n",
"
111067
\n",
"
26426115
\n",
"
10/04/2013 12:00:28 AM
\n",
"
10/04/2013 04:17:32 AM
\n",
"
NYPD
\n",
"
New York City Police Department
\n",
"
Noise - Commercial
\n",
"
Loud Talking
\n",
"
Club/Bar/Restaurant
\n",
"
11226
\n",
"
1233 FLATBUSH AVENUE
\n",
"
FLATBUSH AVENUE
\n",
"
AVENUE D
\n",
"
NEWKIRK AVENUE
\n",
"
NaN
\n",
"
NaN
\n",
"
ADDRESS
\n",
"
BROOKLYN
\n",
"
NaN
\n",
"
Precinct
\n",
"
Closed
\n",
"
10/04/2013 08:00:28 AM
\n",
"
10/04/2013 04:17:32 AM
\n",
"
14 BROOKLYN
\n",
"
BROOKLYN
\n",
"
996654.0
\n",
"
172515.0
\n",
"
Unspecified
\n",
"
BROOKLYN
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
N
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
40.640182
\n",
"
-73.955306
\n",
"
(40.64018174662485, -73.95530566958138)
\n",
"
\n",
"
\n",
"
111068
\n",
"
26428033
\n",
"
10/04/2013 12:00:10 AM
\n",
"
10/04/2013 01:20:52 AM
\n",
"
NYPD
\n",
"
New York City Police Department
\n",
"
Blocked Driveway
\n",
"
Partial Access
\n",
"
Street/Sidewalk
\n",
"
11236
\n",
"
1259 EAST 94 STREET
\n",
"
EAST 94 STREET
\n",
"
AVENUE J
\n",
"
AVENUE K
\n",
"
NaN
\n",
"
NaN
\n",
"
ADDRESS
\n",
"
BROOKLYN
\n",
"
NaN
\n",
"
Precinct
\n",
"
Closed
\n",
"
10/04/2013 08:00:10 AM
\n",
"
10/04/2013 01:20:52 AM
\n",
"
18 BROOKLYN
\n",
"
BROOKLYN
\n",
"
1011804.0
\n",
"
172470.0
\n",
"
Unspecified
\n",
"
BROOKLYN
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
N
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
40.640024
\n",
"
-73.900717
\n",
"
(40.640024057399216, -73.90071711703163)
\n",
"
\n",
" \n",
"
\n",
"
111069 rows × 52 columns
\n",
"
"
],
"text/plain": [
" Unique Key Created Date Closed Date Agency Agency Name Complaint Type Descriptor Location Type Incident Zip Incident Address Street Name Cross Street 1 Cross Street 2 Intersection Street 1 Intersection Street 2 Address Type City Landmark Facility Type Status Due Date Resolution Action Updated Date Community Board Borough X Coordinate (State Plane) Y Coordinate (State Plane) Park Facility Name Park Borough School Name School Number School Region School Code School Phone Number School Address School City School State School Zip School Not Found School or Citywide Complaint Vehicle Type Taxi Company Borough Taxi Pick Up Location Bridge Highway Name Bridge Highway Direction Road Ramp Bridge Highway Segment Garage Lot Name Ferry Direction Ferry Terminal Name Latitude Longitude Location\n",
"0 26589651 10/31/2013 02:08:41 AM NaN NYPD New York City Police Department Noise - Street/Sidewalk Loud Talking Street/Sidewalk 11432 90-03 169 STREET 169 STREET 90 AVENUE 91 AVENUE NaN NaN ADDRESS JAMAICA NaN Precinct Assigned 10/31/2013 10:08:41 AM 10/31/2013 02:35:17 AM 12 QUEENS QUEENS 1042027.0 197389.0 Unspecified QUEENS Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.708275 -73.791604 (40.70827532593202, -73.79160395779721)\n",
"1 26593698 10/31/2013 02:01:04 AM NaN NYPD New York City Police Department Illegal Parking Commercial Overnight Parking Street/Sidewalk 11378 58 AVENUE 58 AVENUE 58 PLACE 59 STREET NaN NaN BLOCKFACE MASPETH NaN Precinct Open 10/31/2013 10:01:04 AM NaN 05 QUEENS QUEENS 1009349.0 201984.0 Unspecified QUEENS Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.721041 -73.909453 (40.721040535628305, -73.90945306791765)\n",
"2 26594139 10/31/2013 02:00:24 AM 10/31/2013 02:40:32 AM NYPD New York City Police Department Noise - Commercial Loud Music/Party Club/Bar/Restaurant 10032 4060 BROADWAY BROADWAY WEST 171 STREET WEST 172 STREET NaN NaN ADDRESS NEW YORK NaN Precinct Closed 10/31/2013 10:00:24 AM 10/31/2013 02:39:42 AM 12 MANHATTAN MANHATTAN 1001088.0 246531.0 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.843330 -73.939144 (40.84332975466513, -73.93914371913482)\n",
"3 26595721 10/31/2013 01:56:23 AM 10/31/2013 02:21:48 AM NYPD New York City Police Department Noise - Vehicle Car/Truck Horn Street/Sidewalk 10023 WEST 72 STREET WEST 72 STREET COLUMBUS AVENUE AMSTERDAM AVENUE NaN NaN BLOCKFACE NEW YORK NaN Precinct Closed 10/31/2013 09:56:23 AM 10/31/2013 02:21:10 AM 07 MANHATTAN MANHATTAN 989730.0 222727.0 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.778009 -73.980213 (40.7780087446372, -73.98021349023975)\n",
"4 26590930 10/31/2013 01:53:44 AM NaN DOHMH Department of Health and Mental Hygiene Rodent Condition Attracting Rodents Vacant Lot 10027 WEST 124 STREET WEST 124 STREET LENOX AVENUE ADAM CLAYTON POWELL JR BOULEVARD NaN NaN BLOCKFACE NEW YORK NaN NaN Pending 11/30/2013 01:53:44 AM 10/31/2013 01:59:54 AM 10 MANHATTAN MANHATTAN 998815.0 233545.0 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.807691 -73.947387 (40.80769092704951, -73.94738703491433)\n",
"... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...\n",
"111064 26426013 10/04/2013 12:01:13 AM 10/07/2013 04:07:16 PM DPR Department of Parks and Recreation Maintenance or Facility Structure - Outdoors Park 11213 NaN NaN NaN NaN NaN NaN NaN BROOKLYN NaN NaN Closed 10/18/2013 12:01:13 AM 10/07/2013 04:07:16 PM 08 BROOKLYN BROOKLYN NaN NaN Brower Park BROOKLYN Brower Park B012 NaN NaN 7189658900 Brooklyn, St. Marks, Kingston Avenues, Park Place BROOKLYN NY 11213 N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN\n",
"111065 26428083 10/04/2013 12:01:05 AM 10/04/2013 02:13:50 AM NYPD New York City Police Department Illegal Parking Posted Parking Sign Violation Street/Sidewalk 11434 NaN NaN NaN NaN GUY R BREWER BOULEVARD ROCKAWAY BOULEVARD INTERSECTION JAMAICA NaN Precinct Closed 10/04/2013 08:01:05 AM 10/04/2013 02:13:50 AM 13 QUEENS QUEENS 1048801.0 178419.0 Unspecified QUEENS Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.656160 -73.767353 (40.656160351546845, -73.76735262738222)\n",
"111066 26428987 10/04/2013 12:00:45 AM 10/04/2013 01:25:01 AM NYPD New York City Police Department Noise - Street/Sidewalk Loud Talking Street/Sidewalk 10016 344 EAST 28 STREET EAST 28 STREET MOUNT CARMEL PLACE 1 AVENUE NaN NaN ADDRESS NEW YORK NaN Precinct Closed 10/04/2013 08:00:45 AM 10/04/2013 01:25:01 AM 06 MANHATTAN MANHATTAN 990637.0 208987.0 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.740295 -73.976952 (40.740295354643706, -73.97695165980414)\n",
"111067 26426115 10/04/2013 12:00:28 AM 10/04/2013 04:17:32 AM NYPD New York City Police Department Noise - Commercial Loud Talking Club/Bar/Restaurant 11226 1233 FLATBUSH AVENUE FLATBUSH AVENUE AVENUE D NEWKIRK AVENUE NaN NaN ADDRESS BROOKLYN NaN Precinct Closed 10/04/2013 08:00:28 AM 10/04/2013 04:17:32 AM 14 BROOKLYN BROOKLYN 996654.0 172515.0 Unspecified BROOKLYN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.640182 -73.955306 (40.64018174662485, -73.95530566958138)\n",
"111068 26428033 10/04/2013 12:00:10 AM 10/04/2013 01:20:52 AM NYPD New York City Police Department Blocked Driveway Partial Access Street/Sidewalk 11236 1259 EAST 94 STREET EAST 94 STREET AVENUE J AVENUE K NaN NaN ADDRESS BROOKLYN NaN Precinct Closed 10/04/2013 08:00:10 AM 10/04/2013 01:20:52 AM 18 BROOKLYN BROOKLYN 1011804.0 172470.0 Unspecified BROOKLYN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.640024 -73.900717 (40.640024057399216, -73.90071711703163)\n",
"\n",
"[111069 rows x 52 columns]"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"complaints"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 2.2 Selecting columns and rows"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To select a column, we index with the name of the column, like this:"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 Noise - Street/Sidewalk\n",
"1 Illegal Parking\n",
"2 Noise - Commercial\n",
"3 Noise - Vehicle\n",
"4 Rodent\n",
" ... \n",
"111064 Maintenance or Facility\n",
"111065 Illegal Parking\n",
"111066 Noise - Street/Sidewalk\n",
"111067 Noise - Commercial\n",
"111068 Blocked Driveway\n",
"Name: Complaint Type, Length: 111069, dtype: object"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"complaints['Complaint Type']"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To get the first 5 rows of a dataframe, we can use a slice: `df[:5]`.\n",
"\n",
"This is a great way to get a sense for what kind of information is in the dataframe -- take a minute to look at the contents and get a feel for this dataset."
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
"
\n",
"
\n",
"
Unique Key
\n",
"
Created Date
\n",
"
Closed Date
\n",
"
Agency
\n",
"
Agency Name
\n",
"
Complaint Type
\n",
"
Descriptor
\n",
"
Location Type
\n",
"
Incident Zip
\n",
"
Incident Address
\n",
"
Street Name
\n",
"
Cross Street 1
\n",
"
Cross Street 2
\n",
"
Intersection Street 1
\n",
"
Intersection Street 2
\n",
"
Address Type
\n",
"
City
\n",
"
Landmark
\n",
"
Facility Type
\n",
"
Status
\n",
"
Due Date
\n",
"
Resolution Action Updated Date
\n",
"
Community Board
\n",
"
Borough
\n",
"
X Coordinate (State Plane)
\n",
"
Y Coordinate (State Plane)
\n",
"
Park Facility Name
\n",
"
Park Borough
\n",
"
School Name
\n",
"
School Number
\n",
"
School Region
\n",
"
School Code
\n",
"
School Phone Number
\n",
"
School Address
\n",
"
School City
\n",
"
School State
\n",
"
School Zip
\n",
"
School Not Found
\n",
"
School or Citywide Complaint
\n",
"
Vehicle Type
\n",
"
Taxi Company Borough
\n",
"
Taxi Pick Up Location
\n",
"
Bridge Highway Name
\n",
"
Bridge Highway Direction
\n",
"
Road Ramp
\n",
"
Bridge Highway Segment
\n",
"
Garage Lot Name
\n",
"
Ferry Direction
\n",
"
Ferry Terminal Name
\n",
"
Latitude
\n",
"
Longitude
\n",
"
Location
\n",
"
\n",
" \n",
" \n",
"
\n",
"
0
\n",
"
26589651
\n",
"
10/31/2013 02:08:41 AM
\n",
"
NaN
\n",
"
NYPD
\n",
"
New York City Police Department
\n",
"
Noise - Street/Sidewalk
\n",
"
Loud Talking
\n",
"
Street/Sidewalk
\n",
"
11432
\n",
"
90-03 169 STREET
\n",
"
169 STREET
\n",
"
90 AVENUE
\n",
"
91 AVENUE
\n",
"
NaN
\n",
"
NaN
\n",
"
ADDRESS
\n",
"
JAMAICA
\n",
"
NaN
\n",
"
Precinct
\n",
"
Assigned
\n",
"
10/31/2013 10:08:41 AM
\n",
"
10/31/2013 02:35:17 AM
\n",
"
12 QUEENS
\n",
"
QUEENS
\n",
"
1042027.0
\n",
"
197389.0
\n",
"
Unspecified
\n",
"
QUEENS
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
N
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
40.708275
\n",
"
-73.791604
\n",
"
(40.70827532593202, -73.79160395779721)
\n",
"
\n",
"
\n",
"
1
\n",
"
26593698
\n",
"
10/31/2013 02:01:04 AM
\n",
"
NaN
\n",
"
NYPD
\n",
"
New York City Police Department
\n",
"
Illegal Parking
\n",
"
Commercial Overnight Parking
\n",
"
Street/Sidewalk
\n",
"
11378
\n",
"
58 AVENUE
\n",
"
58 AVENUE
\n",
"
58 PLACE
\n",
"
59 STREET
\n",
"
NaN
\n",
"
NaN
\n",
"
BLOCKFACE
\n",
"
MASPETH
\n",
"
NaN
\n",
"
Precinct
\n",
"
Open
\n",
"
10/31/2013 10:01:04 AM
\n",
"
NaN
\n",
"
05 QUEENS
\n",
"
QUEENS
\n",
"
1009349.0
\n",
"
201984.0
\n",
"
Unspecified
\n",
"
QUEENS
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
N
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
40.721041
\n",
"
-73.909453
\n",
"
(40.721040535628305, -73.90945306791765)
\n",
"
\n",
"
\n",
"
2
\n",
"
26594139
\n",
"
10/31/2013 02:00:24 AM
\n",
"
10/31/2013 02:40:32 AM
\n",
"
NYPD
\n",
"
New York City Police Department
\n",
"
Noise - Commercial
\n",
"
Loud Music/Party
\n",
"
Club/Bar/Restaurant
\n",
"
10032
\n",
"
4060 BROADWAY
\n",
"
BROADWAY
\n",
"
WEST 171 STREET
\n",
"
WEST 172 STREET
\n",
"
NaN
\n",
"
NaN
\n",
"
ADDRESS
\n",
"
NEW YORK
\n",
"
NaN
\n",
"
Precinct
\n",
"
Closed
\n",
"
10/31/2013 10:00:24 AM
\n",
"
10/31/2013 02:39:42 AM
\n",
"
12 MANHATTAN
\n",
"
MANHATTAN
\n",
"
1001088.0
\n",
"
246531.0
\n",
"
Unspecified
\n",
"
MANHATTAN
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
N
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
40.843330
\n",
"
-73.939144
\n",
"
(40.84332975466513, -73.93914371913482)
\n",
"
\n",
"
\n",
"
3
\n",
"
26595721
\n",
"
10/31/2013 01:56:23 AM
\n",
"
10/31/2013 02:21:48 AM
\n",
"
NYPD
\n",
"
New York City Police Department
\n",
"
Noise - Vehicle
\n",
"
Car/Truck Horn
\n",
"
Street/Sidewalk
\n",
"
10023
\n",
"
WEST 72 STREET
\n",
"
WEST 72 STREET
\n",
"
COLUMBUS AVENUE
\n",
"
AMSTERDAM AVENUE
\n",
"
NaN
\n",
"
NaN
\n",
"
BLOCKFACE
\n",
"
NEW YORK
\n",
"
NaN
\n",
"
Precinct
\n",
"
Closed
\n",
"
10/31/2013 09:56:23 AM
\n",
"
10/31/2013 02:21:10 AM
\n",
"
07 MANHATTAN
\n",
"
MANHATTAN
\n",
"
989730.0
\n",
"
222727.0
\n",
"
Unspecified
\n",
"
MANHATTAN
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
N
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
40.778009
\n",
"
-73.980213
\n",
"
(40.7780087446372, -73.98021349023975)
\n",
"
\n",
"
\n",
"
4
\n",
"
26590930
\n",
"
10/31/2013 01:53:44 AM
\n",
"
NaN
\n",
"
DOHMH
\n",
"
Department of Health and Mental Hygiene
\n",
"
Rodent
\n",
"
Condition Attracting Rodents
\n",
"
Vacant Lot
\n",
"
10027
\n",
"
WEST 124 STREET
\n",
"
WEST 124 STREET
\n",
"
LENOX AVENUE
\n",
"
ADAM CLAYTON POWELL JR BOULEVARD
\n",
"
NaN
\n",
"
NaN
\n",
"
BLOCKFACE
\n",
"
NEW YORK
\n",
"
NaN
\n",
"
NaN
\n",
"
Pending
\n",
"
11/30/2013 01:53:44 AM
\n",
"
10/31/2013 01:59:54 AM
\n",
"
10 MANHATTAN
\n",
"
MANHATTAN
\n",
"
998815.0
\n",
"
233545.0
\n",
"
Unspecified
\n",
"
MANHATTAN
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
Unspecified
\n",
"
N
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
NaN
\n",
"
40.807691
\n",
"
-73.947387
\n",
"
(40.80769092704951, -73.94738703491433)
\n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Unique Key Created Date Closed Date Agency Agency Name Complaint Type Descriptor Location Type Incident Zip Incident Address Street Name Cross Street 1 Cross Street 2 Intersection Street 1 Intersection Street 2 Address Type City Landmark Facility Type Status Due Date Resolution Action Updated Date Community Board Borough X Coordinate (State Plane) Y Coordinate (State Plane) Park Facility Name Park Borough School Name School Number School Region School Code School Phone Number School Address School City School State School Zip School Not Found School or Citywide Complaint Vehicle Type Taxi Company Borough Taxi Pick Up Location Bridge Highway Name Bridge Highway Direction Road Ramp Bridge Highway Segment Garage Lot Name Ferry Direction Ferry Terminal Name Latitude Longitude Location\n",
"0 26589651 10/31/2013 02:08:41 AM NaN NYPD New York City Police Department Noise - Street/Sidewalk Loud Talking Street/Sidewalk 11432 90-03 169 STREET 169 STREET 90 AVENUE 91 AVENUE NaN NaN ADDRESS JAMAICA NaN Precinct Assigned 10/31/2013 10:08:41 AM 10/31/2013 02:35:17 AM 12 QUEENS QUEENS 1042027.0 197389.0 Unspecified QUEENS Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.708275 -73.791604 (40.70827532593202, -73.79160395779721)\n",
"1 26593698 10/31/2013 02:01:04 AM NaN NYPD New York City Police Department Illegal Parking Commercial Overnight Parking Street/Sidewalk 11378 58 AVENUE 58 AVENUE 58 PLACE 59 STREET NaN NaN BLOCKFACE MASPETH NaN Precinct Open 10/31/2013 10:01:04 AM NaN 05 QUEENS QUEENS 1009349.0 201984.0 Unspecified QUEENS Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.721041 -73.909453 (40.721040535628305, -73.90945306791765)\n",
"2 26594139 10/31/2013 02:00:24 AM 10/31/2013 02:40:32 AM NYPD New York City Police Department Noise - Commercial Loud Music/Party Club/Bar/Restaurant 10032 4060 BROADWAY BROADWAY WEST 171 STREET WEST 172 STREET NaN NaN ADDRESS NEW YORK NaN Precinct Closed 10/31/2013 10:00:24 AM 10/31/2013 02:39:42 AM 12 MANHATTAN MANHATTAN 1001088.0 246531.0 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.843330 -73.939144 (40.84332975466513, -73.93914371913482)\n",
"3 26595721 10/31/2013 01:56:23 AM 10/31/2013 02:21:48 AM NYPD New York City Police Department Noise - Vehicle Car/Truck Horn Street/Sidewalk 10023 WEST 72 STREET WEST 72 STREET COLUMBUS AVENUE AMSTERDAM AVENUE NaN NaN BLOCKFACE NEW YORK NaN Precinct Closed 10/31/2013 09:56:23 AM 10/31/2013 02:21:10 AM 07 MANHATTAN MANHATTAN 989730.0 222727.0 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.778009 -73.980213 (40.7780087446372, -73.98021349023975)\n",
"4 26590930 10/31/2013 01:53:44 AM NaN DOHMH Department of Health and Mental Hygiene Rodent Condition Attracting Rodents Vacant Lot 10027 WEST 124 STREET WEST 124 STREET LENOX AVENUE ADAM CLAYTON POWELL JR BOULEVARD NaN NaN BLOCKFACE NEW YORK NaN NaN Pending 11/30/2013 01:53:44 AM 10/31/2013 01:59:54 AM 10 MANHATTAN MANHATTAN 998815.0 233545.0 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.807691 -73.947387 (40.80769092704951, -73.94738703491433)"
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"complaints[:5]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can combine these to get the first 5 rows of a column:"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 Noise - Street/Sidewalk\n",
"1 Illegal Parking\n",
"2 Noise - Commercial\n",
"3 Noise - Vehicle\n",
"4 Rodent\n",
"Name: Complaint Type, dtype: object"
]
},
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"complaints['Complaint Type'][:5]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"and it doesn't matter which direction we do it in:"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 Noise - Street/Sidewalk\n",
"1 Illegal Parking\n",
"2 Noise - Commercial\n",
"3 Noise - Vehicle\n",
"4 Rodent\n",
"Name: Complaint Type, dtype: object"
]
},
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"complaints[:5]['Complaint Type']"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 2.3 Selecting multiple columns"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"What if we just want to know the complaint type and the borough, but not the rest of the information? Pandas makes it really easy to select a subset of the columns: just index with list of columns you want."
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
"
\n",
"
\n",
"
Complaint Type
\n",
"
Borough
\n",
"
\n",
" \n",
" \n",
"
\n",
"
0
\n",
"
Noise - Street/Sidewalk
\n",
"
QUEENS
\n",
"
\n",
"
\n",
"
1
\n",
"
Illegal Parking
\n",
"
QUEENS
\n",
"
\n",
"
\n",
"
2
\n",
"
Noise - Commercial
\n",
"
MANHATTAN
\n",
"
\n",
"
\n",
"
3
\n",
"
Noise - Vehicle
\n",
"
MANHATTAN
\n",
"
\n",
"
\n",
"
4
\n",
"
Rodent
\n",
"
MANHATTAN
\n",
"
\n",
"
\n",
"
...
\n",
"
...
\n",
"
...
\n",
"
\n",
"
\n",
"
111064
\n",
"
Maintenance or Facility
\n",
"
BROOKLYN
\n",
"
\n",
"
\n",
"
111065
\n",
"
Illegal Parking
\n",
"
QUEENS
\n",
"
\n",
"
\n",
"
111066
\n",
"
Noise - Street/Sidewalk
\n",
"
MANHATTAN
\n",
"
\n",
"
\n",
"
111067
\n",
"
Noise - Commercial
\n",
"
BROOKLYN
\n",
"
\n",
"
\n",
"
111068
\n",
"
Blocked Driveway
\n",
"
BROOKLYN
\n",
"
\n",
" \n",
"
\n",
"
111069 rows × 2 columns
\n",
"
"
],
"text/plain": [
" Complaint Type Borough\n",
"0 Noise - Street/Sidewalk QUEENS\n",
"1 Illegal Parking QUEENS\n",
"2 Noise - Commercial MANHATTAN\n",
"3 Noise - Vehicle MANHATTAN\n",
"4 Rodent MANHATTAN\n",
"... ... ...\n",
"111064 Maintenance or Facility BROOKLYN\n",
"111065 Illegal Parking QUEENS\n",
"111066 Noise - Street/Sidewalk MANHATTAN\n",
"111067 Noise - Commercial BROOKLYN\n",
"111068 Blocked Driveway BROOKLYN\n",
"\n",
"[111069 rows x 2 columns]"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"complaints[['Complaint Type', 'Borough']]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"That showed us a summary, and then we can look at the first 10 rows:"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"