Chapter 2 - Selecting and finding desired data

# The usual preamble
%matplotlib inline
import pandas as pd
import matplotlib.pyplot as plt

# Make the graphs a bit prettier, and bigger
pd.set_option('display.mpl_style', 'default')

# This is necessary to show lots of columns in pandas 0.12. 
# Not necessary in pandas 0.13.
pd.set_option('display.width', 5000) 
pd.set_option('display.max_columns', 60)

plt.rcParams['figure.figsize'] = (15, 5)

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. Download the file 311-service-requests.csv.

complaints = pd.read_csv('311-service-requests.csv')

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.

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.

2.1 What’s even in it? (the summary)

When you print a large dataframe, it will only show you the first few rows. 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.

complaints

Output:

Unique KeyCreated DateClosed DateAgencyAgency NameComplaint TypeDescriptorLocation TypeIncident ZipIncident AddressStreet NameCross Street 1Cross Street 2Intersection Street 1Intersection Street 2Address TypeCityLandmarkFacility TypeStatusDue DateResolution Action Updated DateCommunity BoardBoroughX Coordinate (State Plane)Y Coordinate (State Plane)Park Facility NamePark BoroughSchool NameSchool NumberSchool RegionSchool CodeSchool Phone NumberSchool AddressSchool CitySchool StateSchool ZipSchool Not FoundSchool or Citywide ComplaintVehicle TypeTaxi Company BoroughTaxi Pick Up LocationBridge Highway NameBridge Highway DirectionRoad RampBridge Highway SegmentGarage Lot NameFerry DirectionFerry Terminal NameLatitudeLongitudeLocation
02658965110/31/2013 02:08:41 AMNaNNYPDNew York City Police DepartmentNoise - Street/SidewalkLoud TalkingStreet/Sidewalk1143290-03 169 STREET169 STREET90 AVENUE91 AVENUENaNNaNADDRESSJAMAICANaNPrecinctAssigned10/31/2013 10:08:41 AM10/31/2013 02:35:17 AM12 QUEENSQUEENS1042027197389UnspecifiedQUEENSUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.708275-73.791604(40.70827532593202, -73.79160395779721)
12659369810/31/2013 02:01:04 AMNaNNYPDNew York City Police DepartmentIllegal ParkingCommercial Overnight ParkingStreet/Sidewalk1137858 AVENUE58 AVENUE58 PLACE59 STREETNaNNaNBLOCKFACEMASPETHNaNPrecinctOpen10/31/2013 10:01:04 AMNaN05 QUEENSQUEENS1009349201984UnspecifiedQUEENSUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.721041-73.909453(40.721040535628305, -73.90945306791765)
22659413910/31/2013 02:00:24 AM10/31/2013 02:40:32 AMNYPDNew York City Police DepartmentNoise - CommercialLoud Music/PartyClub/Bar/Restaurant100324060 BROADWAYBROADWAYWEST 171 STREETWEST 172 STREETNaNNaNADDRESSNEW YORKNaNPrecinctClosed10/31/2013 10:00:24 AM10/31/2013 02:39:42 AM12 MANHATTANMANHATTAN1001088246531UnspecifiedMANHATTANUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.843330-73.939144(40.84332975466513, -73.93914371913482)
32659572110/31/2013 01:56:23 AM10/31/2013 02:21:48 AMNYPDNew York City Police DepartmentNoise - VehicleCar/Truck HornStreet/Sidewalk10023WEST 72 STREETWEST 72 STREETCOLUMBUS AVENUEAMSTERDAM AVENUENaNNaNBLOCKFACENEW YORKNaNPrecinctClosed10/31/2013 09:56:23 AM10/31/2013 02:21:10 AM07 MANHATTANMANHATTAN989730222727UnspecifiedMANHATTANUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.778009-73.980213(40.7780087446372, -73.98021349023975)
42659093010/31/2013 01:53:44 AMNaNDOHMHDepartment of Health and Mental HygieneRodentCondition Attracting RodentsVacant Lot10027WEST 124 STREETWEST 124 STREETLENOX AVENUEADAM CLAYTON POWELL JR BOULEVARDNaNNaNBLOCKFACENEW YORKNaNNaNPending11/30/2013 01:53:44 AM10/31/2013 01:59:54 AM10 MANHATTANMANHATTAN998815233545UnspecifiedMANHATTANUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.807691-73.947387(40.80769092704951, -73.94738703491433)
52659237010/31/2013 01:46:52 AMNaNNYPDNew York City Police DepartmentNoise - CommercialBanging/PoundingClub/Bar/Restaurant1137237 AVENUE37 AVENUE84 STREET85 STREETNaNNaNBLOCKFACEJACKSON HEIGHTSNaNPrecinctOpen10/31/2013 09:46:52 AMNaN03 QUEENSQUEENS1016948212540UnspecifiedQUEENSUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.749989-73.881988(40.7499893014072, -73.88198770727831)
62659568210/31/2013 01:46:40 AMNaNNYPDNew York City Police DepartmentBlocked DrivewayNo AccessStreet/Sidewalk11419107-50 109 STREET109 STREET107 AVENUE109 AVENUENaNNaNADDRESSSOUTH RICHMOND HILLNaNPrecinctAssigned10/31/2013 09:46:40 AM10/31/2013 01:59:51 AM10 QUEENSQUEENS1030919187622UnspecifiedQUEENSUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.681533-73.831737(40.68153278675525, -73.83173699701601)
72659519510/31/2013 01:44:19 AM10/31/2013 01:58:49 AMNYPDNew York City Police DepartmentNoise - CommercialLoud Music/PartyClub/Bar/Restaurant11417137-09 CROSSBAY BOULEVARDCROSSBAY BOULEVARDPITKIN AVENUEVAN WICKLEN ROADNaNNaNADDRESSOZONE PARKNaNPrecinctClosed10/31/2013 09:44:19 AM10/31/2013 01:58:49 AM10 QUEENSQUEENS1027776184076UnspecifiedQUEENSUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.671816-73.843092(40.67181584567338, -73.84309181950769)
82659054010/31/2013 01:44:14 AM10/31/2013 02:28:04 AMNYPDNew York City Police DepartmentNoise - CommercialLoud TalkingClub/Bar/Restaurant10011258 WEST 15 STREETWEST 15 STREET7 AVENUE8 AVENUENaNNaNADDRESSNEW YORKNaNPrecinctClosed10/31/2013 09:44:14 AM10/31/2013 02:00:56 AM04 MANHATTANMANHATTAN984031208847UnspecifiedMANHATTANUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.739913-74.000790(40.73991339303542, -74.00079028612932)
92659439210/31/2013 01:34:41 AM10/31/2013 02:23:51 AMNYPDNew York City Police DepartmentNoise - CommercialLoud Music/PartyClub/Bar/Restaurant11225835 NOSTRAND AVENUENOSTRAND AVENUEUNION STREETPRESIDENT STREETNaNNaNADDRESSBROOKLYNNaNPrecinctClosed10/31/2013 09:34:41 AM10/31/2013 01:48:26 AM09 BROOKLYNBROOKLYN997941182725UnspecifiedBROOKLYNUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.668204-73.950648(40.66820406598287, -73.95064760056546)
102659517610/31/2013 01:25:12 AMNaNNYPDNew York City Police DepartmentNoise - House of WorshipLoud Music/PartyHouse of Worship112183775 18 AVENUE18 AVENUEEAST 9 STREETEAST 8 STREETNaNNaNADDRESSBROOKLYNNaNPrecinctOpen10/31/2013 09:25:12 AMNaN14 BROOKLYNBROOKLYN992726170399UnspecifiedBROOKLYNUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.634378-73.969462(40.63437840816299, -73.96946177104543)
112659198210/31/2013 01:24:14 AM10/31/2013 01:54:39 AMNYPDNew York City Police DepartmentNoise - CommercialLoud Music/PartyClub/Bar/Restaurant10003187 2 AVENUE2 AVENUEEAST 11 STREETEAST 12 STREETNaNNaNADDRESSNEW YORKNaNPrecinctClosed10/31/2013 09:24:14 AM10/31/2013 01:54:39 AM03 MANHATTANMANHATTAN988110205533UnspecifiedMANHATTANUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.730816-73.986073(40.73081644089586, -73.98607265739876)
122659416910/31/2013 01:20:57 AM10/31/2013 02:12:31 AMNYPDNew York City Police DepartmentIllegal ParkingDouble Parked Blocking VehicleStreet/Sidewalk1002965 EAST 99 STREETEAST 99 STREETMADISON AVENUEPARK AVENUENaNNaNADDRESSNEW YORKNaNPrecinctClosed10/31/2013 09:20:57 AM10/31/2013 01:42:05 AM11 MANHATTANMANHATTAN997470226725UnspecifiedMANHATTANUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.788974-73.952259(40.78897400211689, -73.95225898702977)
132659439110/31/2013 01:20:13 AMNaNNYPDNew York City Police DepartmentNoise - VehicleEngine IdlingStreet/Sidewalk10466NaNNaNNaNNaNSTRANG AVENUEAMUNDSON AVENUEINTERSECTIONBRONXNaNPrecinctOpen10/31/2013 09:20:13 AMNaN12 BRONXBRONX1029467264124UnspecifiedBRONXUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.891517-73.836457(40.89151738488846, -73.83645714593568)
142659091710/31/2013 01:19:54 AMNaNDOHMHDepartment of Health and Mental HygieneRodentRat Sighting1-2 Family Mixed Use Building1121963 STREET63 STREET13 AVENUE14 AVENUENaNNaNBLOCKFACEBROOKLYNNaNNaNPending11/30/2013 01:19:54 AM10/31/2013 01:29:26 AM10 BROOKLYNBROOKLYN984467167519UnspecifiedBROOKLYNUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.626477-73.999218(40.6264774690411, -73.99921826202639)
152659145810/31/2013 01:14:02 AM10/31/2013 01:30:34 AMNYPDNew York City Police DepartmentNoise - House of WorshipLoud Music/PartyHouse of Worship10025NaNNaNNaNNaNWEST 99 STREETBROADWAYINTERSECTIONNEW YORKNaNPrecinctClosed10/31/2013 09:14:02 AM10/31/2013 01:30:34 AM07 MANHATTANMANHATTAN992454229500UnspecifiedMANHATTANUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.796597-73.970370(40.7965967075252, -73.97036973473399)
162659408610/31/2013 12:54:03 AM10/31/2013 02:16:39 AMNYPDNew York City Police DepartmentNoise - Street/SidewalkLoud Music/PartyStreet/Sidewalk10310173 CAMPBELL AVENUECAMPBELL AVENUEHENDERSON AVENUEWINEGAR LANENaNNaNADDRESSSTATEN ISLANDNaNPrecinctClosed10/31/2013 08:54:03 AM10/31/2013 02:07:14 AM01 STATEN ISLANDSTATEN ISLAND952013171076UnspecifiedSTATEN ISLANDUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.636182-74.116150(40.63618202176914, -74.1161500428337)
172659511710/31/2013 12:52:46 AMNaNNYPDNew York City Police DepartmentIllegal ParkingPosted Parking Sign ViolationStreet/Sidewalk11236NaNNaNNaNNaNROCKAWAY PARKWAYSKIDMORE AVENUEINTERSECTIONBROOKLYNNaNPrecinctOpen10/31/2013 08:52:46 AMNaN18 BROOKLYNBROOKLYN1015289169710UnspecifiedBROOKLYNUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.632437-73.888173(40.63243692394328, -73.88817263437012)
182659038910/31/2013 12:51:00 AMNaNDOTDepartment of TransportationStreet Light ConditionStreet Light OutNaNNaN226 42 ST E42 ST ECHURCH AVESNYDER AVENaNNaNADDRESSNaNNaNNaNOpenNaNNaNUnspecified BROOKLYNBROOKLYNNaNNaNUnspecifiedBROOKLYNUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
192659421010/31/2013 12:46:27 AMNaNNYPDNew York City Police DepartmentNoise - CommercialLoud Music/PartyClub/Bar/Restaurant10033NaNNaNNaNNaNWEST 184 STREETBROADWAYINTERSECTIONNEW YORKNaNPrecinctAssigned10/31/2013 08:46:27 AM10/31/2013 01:32:41 AM12 MANHATTANMANHATTAN1002294249712UnspecifiedMANHATTANUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.852058-73.934776(40.85205827756883, -73.93477640780834)
202659293210/31/2013 12:43:47 AM10/31/2013 12:56:20 AMNYPDNew York City Police DepartmentNoise - House of WorshipLoud Music/PartyHouse of Worship11216778 PARK PLACEPARK PLACEROGERS AVENUENOSTRAND AVENUENaNNaNADDRESSBROOKLYNNaNPrecinctClosed10/31/2013 08:43:47 AM10/31/2013 12:56:20 AM08 BROOKLYNBROOKLYN997608184656UnspecifiedBROOKLYNUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.673505-73.951844(40.67350473678714, -73.95184414979961)
212659415210/31/2013 12:41:17 AM10/31/2013 01:04:37 AMNYPDNew York City Police DepartmentNoise - CommercialBanging/PoundingStore/Commercial10016155 E 34TH STE 34TH STNaNNaNNaNNaNLATLONGNEW YORKNaNPrecinctClosed10/31/2013 08:41:17 AM10/31/2013 01:04:38 AM06 MANHATTANMANHATTAN990133211136UnspecifiedMANHATTANUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.746194-73.978769(40.74619417253121, -73.97876853124392)
222658967810/31/2013 12:39:55 AMNaNNYPDNew York City Police DepartmentNoise - VehicleCar/Truck MusicStreet/Sidewalk11419NaNNaNNaNNaN112 STREETATLANTIC AVENUEINTERSECTIONSOUTH RICHMOND HILLNaNPrecinctOpen10/31/2013 08:39:55 AMNaN09 QUEENSQUEENS1030314191578UnspecifiedQUEENSUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.692394-73.833891(40.69239424979043, -73.8338912453996)
232659230410/31/2013 12:38:00 AMNaNNYPDNew York City Police DepartmentNoise - CommercialLoud Music/PartyClub/Bar/Restaurant11216371 TOMPKINS AVENUETOMPKINS AVENUEMADISON STREETPUTNAM AVENUENaNNaNADDRESSBROOKLYNNaNPrecinctAssigned10/31/2013 08:38:00 AM10/31/2013 01:16:53 AM03 BROOKLYNBROOKLYN999720188825UnspecifiedBROOKLYNUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.684944-73.944221(40.6849442562592, -73.94422078036632)
242659189210/31/2013 12:37:16 AMNaNNYPDNew York City Police DepartmentBlocked DrivewayPartial AccessStreet/Sidewalk103051496 BAY STREETBAY STREETLYMAN AVENUESCHOOL ROADNaNNaNADDRESSSTATEN ISLANDNaNPrecinctAssigned10/31/2013 08:37:16 AM10/31/2013 12:52:10 AM01 STATEN ISLANDSTATEN ISLAND967283160518UnspecifiedSTATEN ISLANDUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.607245-74.061106(40.60724493456944, -74.06110566015863)
252659157310/31/2013 12:35:18 AM10/31/2013 02:41:35 AMNYPDNew York City Police DepartmentNoise - Street/SidewalkLoud TalkingStreet/Sidewalk1031224 PRINCETON LANEPRINCETON LANEHAMPTON GREENDEAD ENDNaNNaNADDRESSSTATEN ISLANDNaNPrecinctClosed10/31/2013 08:35:18 AM10/31/2013 01:45:17 AM03 STATEN ISLANDSTATEN ISLAND929577140964UnspecifiedSTATEN ISLANDUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.553421-74.196743(40.55342078716953, -74.19674315017886)
262659050910/31/2013 12:33:00 AMNaNDOTDepartment of TransportationStreet Light ConditionStreet Light OutNaNNaN38 ST E38 ST ECHURCH AVELINDEN BLVDNaNNaNBLOCKFACENaNNaNNaNOpenNaNNaNUnspecified BROOKLYNBROOKLYNNaNNaNUnspecifiedBROOKLYNUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
272659137910/31/2013 12:32:44 AMNaNDOHMHDepartment of Health and Mental HygieneHarboring Bees/WaspsBees/Wasps - Not a beekeper3+ Family Mixed Use Building10025501 WEST 110 STREETWEST 110 STREETAMSTERDAM AVENUEBROADWAYNaNNaNADDRESSNEW YORKNaNNaNOpen11/30/2013 12:32:44 AMNaN09 MANHATTANMANHATTAN994143231888UnspecifiedMANHATTANUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.803149-73.964266(40.80314938553783, -73.96426608076082)
282659408510/31/2013 12:32:08 AMNaNNYPDNew York City Police DepartmentNoise - Street/SidewalkLoud TalkingStreet/Sidewalk10026121 WEST 116 STREETWEST 116 STREETLENOX AVENUE7 AVENUENaNNaNADDRESSNEW YORKNaNPrecinctAssigned10/31/2013 08:32:08 AM10/31/2013 02:00:57 AM10 MANHATTANMANHATTAN997947231613UnspecifiedMANHATTANUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.802390-73.950526(40.80238950799943, -73.95052644123253)
292658920110/31/2013 12:32:00 AMNaNDOTDepartment of TransportationStreet Light ConditionStreet Light OutNaN10309295 BAYVIEW AVENUEBAYVIEW AVENUEVAIL AVENUEBAYVIEW LANENaNNaNADDRESSSTATEN ISLANDNaNNaNOpenNaNNaN03 STATEN ISLANDSTATEN ISLAND927687127837UnspecifiedSTATEN ISLANDUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.517378-74.203435(40.517377871705676, -74.20343466779575)
302659164110/31/2013 12:31:17 AM10/31/2013 02:41:36 AMNYPDNew York City Police DepartmentBlocked DrivewayNo AccessStreet/Sidewalk1031224 PRINCETON LANEPRINCETON LANEHAMPTON GREENDEAD ENDNaNNaNADDRESSSTATEN ISLANDNaNPrecinctClosed10/31/2013 08:31:17 AM10/31/2013 01:43:09 AM03 STATEN ISLANDSTATEN ISLAND929577140964UnspecifiedSTATEN ISLANDUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.553421-74.196743(40.55342078716953, -74.19674315017886)
312659556410/31/2013 12:30:36 AMNaNNYPDNew York City Police DepartmentNoise - Street/SidewalkLoud Music/PartyStreet/Sidewalk11236AVENUE JAVENUE JEAST 80 STREETEAST 81 STREETNaNNaNBLOCKFACEBROOKLYNNaNPrecinctOpen10/31/2013 08:30:36 AMNaN18 BROOKLYNBROOKLYN1008937170310UnspecifiedBROOKLYNUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.634104-73.911055(40.634103775951736, -73.91105541883589)
322659137810/31/2013 12:30:31 AMNaNTLCTaxi and Limousine CommissionTaxi ComplaintDriver ComplaintNaN10036645 10 AVENUE10 AVENUEWEST 45 STREETWEST 46 STREETNaNNaNADDRESSNEW YORKNaNNaNOpenNaNNaN04 MANHATTANMANHATTAN985965216868UnspecifiedMANHATTANUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNOtherNaNNaNNaNNaNNaNNaNNaN40.761929-73.993809(40.761928847500016, -73.99380918401052)
332659387210/31/2013 12:29:47 AM10/31/2013 12:38:29 AMNYPDNew York City Police DepartmentNoise - House of WorshipBanging/PoundingHouse of Worship10025NaNNaNNaNNaNWEST 99 STREETAMSTERDAM AVENUEINTERSECTIONNEW YORKNaNPrecinctClosed10/31/2013 08:29:47 AM10/31/2013 12:38:29 AM07 MANHATTANMANHATTAN992846229279UnspecifiedMANHATTANUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.795990-73.968954(40.795989749917204, -73.96895423714467)
342659142010/31/2013 12:28:30 AM10/31/2013 02:06:11 AMNYPDNew York City Police DepartmentHomeless EncampmentNaNResidential Building/House100252754 BROADWAYBROADWAYWEST 105 STREETWEST 106 STREETNaNNaNADDRESSNEW YORKNaNPrecinctClosed10/31/2013 08:28:30 AM10/31/2013 02:06:11 AM07 MANHATTANMANHATTAN993139231139UnspecifiedMANHATTANUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.801095-73.967894(40.8010946529914, -73.96789356094007)
352659297610/31/2013 12:23:24 AM10/31/2013 01:05:41 AMNYPDNew York City Police DepartmentBlocked DrivewayNo AccessStreet/Sidewalk11433173-41 103 ROAD103 ROAD173 STREET177 STREETNaNNaNADDRESSJAMAICANaNPrecinctClosed10/31/2013 08:23:24 AM10/31/2013 01:05:41 AM12 QUEENSQUEENS1044124195866UnspecifiedQUEENSUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.704081-73.784054(40.70408112125158, -73.78405385422116)
362659026210/31/2013 12:23:00 AMNaNDOTDepartment of TransportationTraffic Signal ConditionControllerNaN11235NaNNaNNaNNaNSHORE BOULEVARDCASS PLACEINTERSECTIONBROOKLYNNaNNaNOpenNaNNaN15 BROOKLYNBROOKLYN997073151225UnspecifiedBROOKLYNUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.581744-73.953836(40.5817444882428, -73.95383634845487)
372658960610/31/2013 12:20:44 AM10/31/2013 02:10:24 AMNYPDNew York City Police DepartmentNoise - CommercialLoud Music/PartyClub/Bar/Restaurant11216826 ST JOHN'S PLACEST JOHN'S PLACEROGERS AVENUENOSTRAND AVENUENaNNaNADDRESSBROOKLYNNaNPrecinctClosed10/31/2013 08:20:44 AM10/31/2013 02:10:24 AM08 BROOKLYNBROOKLYN997865183985UnspecifiedBROOKLYNUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.671663-73.950919(40.671662601079895, -73.95091901534035)
382659208310/31/2013 12:20:00 AMNaNDOTDepartment of TransportationTraffic Signal ConditionControllerNaN11213NaNNaNNaNNaNBUFFALO AVENUEPARK PLACEINTERSECTIONBROOKLYNNaNNaNOpenNaNNaN08 BROOKLYNBROOKLYN1004987184136UnspecifiedBROOKLYNUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.672063-73.925244(40.67206324438088, -73.92524432147842)
392659384010/31/2013 12:19:48 AMNaNNYPDNew York City Police DepartmentBlocked DrivewayNo AccessStreet/Sidewalk1137978-41 68 ROAD68 ROAD78 STREET79 STREETNaNNaNADDRESSMIDDLE VILLAGENaNPrecinctOpen10/31/2013 08:19:48 AMNaN05 QUEENSQUEENS1019062198120UnspecifiedQUEENSUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.710402-73.874433(40.71040190143904, -73.8744325577748)
402658964610/31/2013 12:18:05 AM10/31/2013 01:26:15 AMNYPDNew York City Police DepartmentNoise - CommercialLoud Music/PartyClub/Bar/Restaurant1110134-19 STEINWAY STREETSTEINWAY STREET34 AVENUE35 AVENUENaNNaNADDRESSLONG ISLAND CITYNaNPrecinctClosed10/31/2013 08:18:05 AM10/31/2013 01:26:15 AM01 QUEENSQUEENS1006080214807UnspecifiedQUEENSUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.756245-73.921205(40.75624514774764, -73.92120466494264)
412659329610/31/2013 12:16:25 AMNaNDOHMHDepartment of Health and Mental HygieneFood EstablishmentRodents/Insects/GarbageRestaurant/Bar/Deli/Bakery1001412 CHRISTOPHER STREETCHRISTOPHER STREETGREENWICH AVENUEGAY STREETNaNNaNADDRESSNEW YORKNaNNaNOpen12/07/2013 12:16:25 AMNaN02 MANHATTANMANHATTAN984181206685UnspecifiedMANHATTANUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.733979-74.000249(40.73397924003587, -74.0002489720853)
422659048010/31/2013 12:15:06 AM10/31/2013 03:00:20 AMNYPDNew York City Police DepartmentNoise - CommercialLoud Music/PartyStore/Commercial11231325 COLUMBIA STREETCOLUMBIA STREETNaNNaNNaNNaNLATLONGBROOKLYNNaNPrecinctClosed10/31/2013 08:15:06 AM10/31/2013 02:58:55 AM06 BROOKLYNBROOKLYN982995187440UnspecifiedBROOKLYNUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.681156-74.004525(40.68115617695543, -74.00452481832494)
432658962610/31/2013 12:14:42 AM10/31/2013 01:39:00 AMNYPDNew York City Police DepartmentNoise - CommercialLoud Music/PartyClub/Bar/Restaurant112342192 FLATBUSH AVENUEFLATBUSH AVENUEEAST 46 STREETAVENUE ONaNNaNADDRESSBROOKLYNNaNPrecinctClosed10/31/2013 08:14:42 AM10/31/2013 01:39:00 AM18 BROOKLYNBROOKLYN1003628163910UnspecifiedBROOKLYNUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.616550-73.930202(40.61655032892211, -73.93020153359745)
442659289810/31/2013 12:12:08 AM10/31/2013 01:13:45 AMNYPDNew York City Police DepartmentNoise - ParkLoud TalkingPark/Playground10457CROTONA PARK NORTHCROTONA PARK NORTHCLINTON AVENUEPROSPECT AVENUENaNNaNBLOCKFACEBRONXNaNPrecinctClosed10/31/2013 08:12:08 AM10/31/2013 01:13:45 AM06 BRONXBRONX1013947245819UnspecifiedBRONXUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.841342-73.892672(40.841341641554614, -73.89267161957397)
452659044610/31/2013 12:11:58 AM10/31/2013 01:54:38 AMNYPDNew York City Police DepartmentNoise - Street/SidewalkLoud Music/PartyStreet/Sidewalk10459819 EAST 167 STREETEAST 167 STREETUNION AVENUEPROSPECT AVENUENaNNaNADDRESSBRONXNaNPrecinctClosed10/31/2013 08:11:58 AM10/31/2013 01:54:38 AM03 BRONXBRONX1011935240454UnspecifiedBRONXUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.826623-73.899965(40.826622810177874, -73.8999653556452)
462659554610/31/2013 12:09:07 AM10/31/2013 12:53:12 AMNYPDNew York City Police DepartmentNoise - CommercialLoud Music/PartyClub/Bar/Restaurant104654005 EAST TREMONT AVENUEEAST TREMONT AVENUESAMPSON AVENUEGERBER PLACENaNNaNADDRESSBRONXNaNPrecinctClosed10/31/2013 08:09:07 AM10/31/2013 12:53:12 AM10 BRONXBRONX1034640238172UnspecifiedBRONXUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.820259-73.817942(40.820259030934515, -73.81794234356029)
472659594410/31/2013 12:08:47 AMNaNTLCTaxi and Limousine CommissionTaxi ComplaintDriver ComplaintNaN10036NaNNaNNaNNaNWEST 46 STREET10 AVENUEINTERSECTIONNEW YORKNaNNaNOpen11/14/2013 12:08:47 AMNaN04 MANHATTANMANHATTAN986020216961UnspecifiedMANHATTANUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNOtherNaNNaNNaNNaNNaNNaNNaN40.762184-73.993611(40.76218409774632, -73.99361062023596)
482659508410/31/2013 12:07:45 AM10/31/2013 01:43:11 AMNYPDNew York City Police DepartmentNoise - CommercialLoud Music/PartyClub/Bar/Restaurant1001412 CHRISTOPHER STREETCHRISTOPHER STREETGREENWICH AVENUEGAY STREETNaNNaNADDRESSNEW YORKNaNPrecinctClosed10/31/2013 08:07:45 AM10/31/2013 01:43:11 AM02 MANHATTANMANHATTAN984181206685UnspecifiedMANHATTANUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.733979-74.000249(40.73397924003587, -74.0002489720853)
492659555310/31/2013 12:05:10 AM10/31/2013 02:43:43 AMNYPDNew York City Police DepartmentNoise - Street/SidewalkLoud TalkingStreet/Sidewalk1122525 LEFFERTS AVENUELEFFERTS AVENUEWASHINGTON AVENUEBEDFORD AVENUENaNNaNADDRESSBROOKLYNNaNPrecinctClosed10/31/2013 08:05:10 AM10/31/2013 01:29:29 AM09 BROOKLYNBROOKLYN995366180388UnspecifiedBROOKLYNUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.661793-73.959934(40.6617931276793, -73.95993363978067)
502659408710/31/2013 12:04:50 AM10/31/2013 01:09:38 AMNYPDNew York City Police DepartmentNoise - CommercialLoud Music/PartyStore/Commercial10011258 WEST 15TH STREETWEST 15TH STREETNaNNaNNaNNaNLATLONGNEW YORKNaNPrecinctClosed10/31/2013 08:04:50 AM10/31/2013 01:09:38 AM04 MANHATTANMANHATTAN983789208891UnspecifiedMANHATTANUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.740034-74.001664(40.74003415280169, -74.00166357336052)
512659557210/31/2013 12:03:27 AMNaNDOTDepartment of TransportationBroken Muni MeterNo ReceiptStreet10003NaNNaNNaNNaNEAST 10 STREET2 AVENUEINTERSECTIONNEW YORKNaNNaNOpen11/21/2013 12:03:27 AMNaN03 MANHATTANMANHATTAN987906205154UnspecifiedMANHATTANUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.729776-73.986809(40.72977626532991, -73.98680891976119)
522659084810/31/2013 12:02:01 AM10/31/2013 01:02:28 AMNYPDNew York City Police DepartmentBlocked DrivewayNo AccessStreet/Sidewalk11207422 WYONA STREETWYONA STREETSUTTER AVENUEBLAKE AVENUENaNNaNADDRESSBROOKLYNNaNPrecinctClosed10/31/2013 08:02:01 AM10/31/2013 01:02:28 AM05 BROOKLYNBROOKLYN1014188182855UnspecifiedBROOKLYNUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.668521-73.892081(40.66852085465471, -73.89208096944678)
532659041310/31/2013 12:01:47 AM10/31/2013 12:39:31 AMNYPDNew York City Police DepartmentNoise - CommercialLoud Music/PartyClub/Bar/Restaurant10002121 RIVINGTON STREETRIVINGTON STREETESSEX STREETNORFOLK STREETNaNNaNADDRESSNEW YORKNaNPrecinctClosed10/31/2013 08:01:47 AM10/31/2013 12:39:31 AM03 MANHATTANMANHATTAN987766201503UnspecifiedMANHATTANUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.719755-73.987316(40.71975521311322, -73.98731595609806)
542659128710/31/2013 12:01:45 AM10/31/2013 12:02:37 AMHRAHRA Benefit Card ReplacementBenefit Card ReplacementMedicaidNYC Street AddressNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNClosedNaNNaN0 UnspecifiedUnspecifiedNaNNaNUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
552659500110/31/2013 12:01:34 AM10/31/2013 01:32:43 AMNYPDNew York City Police DepartmentNoise - CommercialLoud Music/PartyStore/Commercial10034524 WEST 207TH STREETWEST 207TH STREETNaNNaNNaNNaNLATLONGNEW YORKNaNPrecinctClosed10/31/2013 08:01:34 AM10/31/2013 01:32:43 AM01 MANHATTANMANHATTAN1006481254514UnspecifiedMANHATTANUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.865229-73.919626(40.86522877164924, -73.91962575276823)
562659116210/31/2013 12:01:00 AMNaNDSNYBCC - Brooklyn SouthSanitation Condition15 Street Cond/Dump-Out/Drop-OffStreet11231135 COLUMBIA STREETCOLUMBIA STREETKANE STREETIRVING STREETNaNNaNADDRESSBROOKLYNNaNDSNY GarageOpenNaNNaN06 BROOKLYNBROOKLYN983797189648UnspecifiedBROOKLYNUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.687217-74.001633(40.68721671044577, -74.00163340956126)
572659345910/31/2013 12:00:00 AMNaNHPDDepartment of Housing Preservation and Develop...ELECTRICELECTRIC-SUPPLYRESIDENTIAL BUILDING11233199 HOWARD AVENUEHOWARD AVENUEBAINBRIDGE STREETCHAUNCEY STREETNaNNaNADDRESSBROOKLYNNaNNaNOpenNaN10/31/2013 12:00:00 AM03 BROOKLYNBROOKLYN1006513187623UnspecifiedBROOKLYNUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.681631-73.919732(40.68163056217252, -73.91973166452124)
582659263410/31/2013 12:00:00 AMNaNHPDDepartment of Housing Preservation and Develop...PLUMBINGBASIN/SINKRESIDENTIAL BUILDING11233199 HOWARD AVENUEHOWARD AVENUEBAINBRIDGE STREETCHAUNCEY STREETNaNNaNADDRESSBROOKLYNNaNNaNOpenNaN10/31/2013 12:00:00 AM03 BROOKLYNBROOKLYN1006513187623UnspecifiedBROOKLYNUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.681631-73.919732(40.68163056217252, -73.91973166452124)
592659168810/31/2013 12:00:00 AMNaNHPDDepartment of Housing Preservation and Develop...HEATINGHEATRESIDENTIAL BUILDING10453150 WEST 179 STREETWEST 179 STREETANDREWS AVENUELORING PLACENaNNaNADDRESSBRONXNaNNaNOpenNaN10/31/2013 12:00:00 AM05 BRONXBRONX1008161250940UnspecifiedBRONXUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.855415-73.913565(40.855414830918306, -73.91356461276855)
............................................................................................................................................................

111069 rows × 52 columns

2.2 Selecting columns and rows

To select a column, we index with the name of the column, like this:

complaints['Complaint Type']

Output:

0      Noise - Street/Sidewalk
1              Illegal Parking
2           Noise - Commercial
3              Noise - Vehicle
4                       Rodent
5           Noise - Commercial
6             Blocked Driveway
7           Noise - Commercial
8           Noise - Commercial
9           Noise - Commercial
10    Noise - House of Worship
11          Noise - Commercial
12             Illegal Parking
13             Noise - Vehicle
14                      Rodent
...
111054    Noise - Street/Sidewalk
111055         Noise - Commercial
111056      Street Sign - Missing
111057                      Noise
111058         Noise - Commercial
111059    Noise - Street/Sidewalk
111060                      Noise
111061         Noise - Commercial
111062               Water System
111063               Water System
111064    Maintenance or Facility
111065            Illegal Parking
111066    Noise - Street/Sidewalk
111067         Noise - Commercial
111068           Blocked Driveway
Name: Complaint Type, Length: 111069, dtype: object

To get the first 5 rows of a dataframe, we can use a slice: df[:5]. 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.

complaints[:5]

Output:

Unique KeyCreated DateClosed DateAgencyAgency NameComplaint TypeDescriptorLocation TypeIncident ZipIncident AddressStreet NameCross Street 1Cross Street 2Intersection Street 1Intersection Street 2Address TypeCityLandmarkFacility TypeStatusDue DateResolution Action Updated DateCommunity BoardBoroughX Coordinate (State Plane)Y Coordinate (State Plane)Park Facility NamePark BoroughSchool NameSchool NumberSchool RegionSchool CodeSchool Phone NumberSchool AddressSchool CitySchool StateSchool ZipSchool Not FoundSchool or Citywide ComplaintVehicle TypeTaxi Company BoroughTaxi Pick Up LocationBridge Highway NameBridge Highway DirectionRoad RampBridge Highway SegmentGarage Lot NameFerry DirectionFerry Terminal NameLatitudeLongitudeLocation
02658965110/31/2013 02:08:41 AMNaNNYPDNew York City Police DepartmentNoise - Street/SidewalkLoud TalkingStreet/Sidewalk1143290-03 169 STREET169 STREET90 AVENUE91 AVENUENaNNaNADDRESSJAMAICANaNPrecinctAssigned10/31/2013 10:08:41 AM10/31/2013 02:35:17 AM12 QUEENSQUEENS1042027197389UnspecifiedQUEENSUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.708275-73.791604(40.70827532593202, -73.79160395779721)
12659369810/31/2013 02:01:04 AMNaNNYPDNew York City Police DepartmentIllegal ParkingCommercial Overnight ParkingStreet/Sidewalk1137858 AVENUE58 AVENUE58 PLACE59 STREETNaNNaNBLOCKFACEMASPETHNaNPrecinctOpen10/31/2013 10:01:04 AMNaN05 QUEENSQUEENS1009349201984UnspecifiedQUEENSUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.721041-73.909453(40.721040535628305, -73.90945306791765)
22659413910/31/2013 02:00:24 AM10/31/2013 02:40:32 AMNYPDNew York City Police DepartmentNoise - CommercialLoud Music/PartyClub/Bar/Restaurant100324060 BROADWAYBROADWAYWEST 171 STREETWEST 172 STREETNaNNaNADDRESSNEW YORKNaNPrecinctClosed10/31/2013 10:00:24 AM10/31/2013 02:39:42 AM12 MANHATTANMANHATTAN1001088246531UnspecifiedMANHATTANUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.843330-73.939144(40.84332975466513, -73.93914371913482)
32659572110/31/2013 01:56:23 AM10/31/2013 02:21:48 AMNYPDNew York City Police DepartmentNoise - VehicleCar/Truck HornStreet/Sidewalk10023WEST 72 STREETWEST 72 STREETCOLUMBUS AVENUEAMSTERDAM AVENUENaNNaNBLOCKFACENEW YORKNaNPrecinctClosed10/31/2013 09:56:23 AM10/31/2013 02:21:10 AM07 MANHATTANMANHATTAN989730222727UnspecifiedMANHATTANUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.778009-73.980213(40.7780087446372, -73.98021349023975)
42659093010/31/2013 01:53:44 AMNaNDOHMHDepartment of Health and Mental HygieneRodentCondition Attracting RodentsVacant Lot10027WEST 124 STREETWEST 124 STREETLENOX AVENUEADAM CLAYTON POWELL JR BOULEVARDNaNNaNBLOCKFACENEW YORKNaNNaNPending11/30/2013 01:53:44 AM10/31/2013 01:59:54 AM10 MANHATTANMANHATTAN998815233545UnspecifiedMANHATTANUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedUnspecifiedNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN40.807691-73.947387(40.80769092704951, -73.94738703491433)

5 rows × 52 columns

We can combine these to get the first 5 rows of a column:

complaints['Complaint Type'][:5]

Output:

0    Noise - Street/Sidewalk
1            Illegal Parking
2         Noise - Commercial
3            Noise - Vehicle
4                     Rodent
Name: Complaint Type, dtype: object

and it doesn’t matter which direction we do it in:

complaints['Complaint Type'][:5]

Output:

0    Noise - Street/Sidewalk
1            Illegal Parking
2         Noise - Commercial
3            Noise - Vehicle
4                     Rodent
Name: Complaint Type, dtype: object

2.3 Selecting multiple columns

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.

complaints[['Complaint Type', 'Borough']]

Output:

Complaint TypeBorough
0Noise - Street/SidewalkQUEENS
1Illegal ParkingQUEENS
2Noise - CommercialMANHATTAN
3Noise - VehicleMANHATTAN
4RodentMANHATTAN
5Noise - CommercialQUEENS
6Blocked DrivewayQUEENS
7Noise - CommercialQUEENS
8Noise - CommercialMANHATTAN
9Noise - CommercialBROOKLYN
10Noise - House of WorshipBROOKLYN
11Noise - CommercialMANHATTAN
12Illegal ParkingMANHATTAN
13Noise - VehicleBRONX
14RodentBROOKLYN
15Noise - House of WorshipMANHATTAN
16Noise - Street/SidewalkSTATEN ISLAND
17Illegal ParkingBROOKLYN
18Street Light ConditionBROOKLYN
19Noise - CommercialMANHATTAN
20Noise - House of WorshipBROOKLYN
21Noise - CommercialMANHATTAN
22Noise - VehicleQUEENS
23Noise - CommercialBROOKLYN
24Blocked DrivewaySTATEN ISLAND
25Noise - Street/SidewalkSTATEN ISLAND
26Street Light ConditionBROOKLYN
27Harboring Bees/WaspsMANHATTAN
28Noise - Street/SidewalkMANHATTAN
29Street Light ConditionSTATEN ISLAND
30Blocked DrivewaySTATEN ISLAND
31Noise - Street/SidewalkBROOKLYN
32Taxi ComplaintMANHATTAN
33Noise - House of WorshipMANHATTAN
34Homeless EncampmentMANHATTAN
35Blocked DrivewayQUEENS
36Traffic Signal ConditionBROOKLYN
37Noise - CommercialBROOKLYN
38Traffic Signal ConditionBROOKLYN
39Blocked DrivewayQUEENS
40Noise - CommercialQUEENS
41Food EstablishmentMANHATTAN
42Noise - CommercialBROOKLYN
43Noise - CommercialBROOKLYN
44Noise - ParkBRONX
45Noise - Street/SidewalkBRONX
46Noise - CommercialBRONX
47Taxi ComplaintMANHATTAN
48Noise - CommercialMANHATTAN
49Noise - Street/SidewalkBROOKLYN
50Noise - CommercialMANHATTAN
51Broken Muni MeterMANHATTAN
52Blocked DrivewayBROOKLYN
53Noise - CommercialMANHATTAN
54Benefit Card ReplacementUnspecified
55Noise - CommercialMANHATTAN
56Sanitation ConditionBROOKLYN
57ELECTRICBROOKLYN
58PLUMBINGBROOKLYN
59HEATINGBRONX
......

111069 rows × 2 columns

That showed us a summary, and then we can look at the first 10 rows:

complaints[['Complaint Type', 'Borough']][:10]

Output:

Complaint TypeBorough
0Noise - Street/SidewalkQUEENS
1Illegal ParkingQUEENS
2Noise - CommercialMANHATTAN
3Noise - VehicleMANHATTAN
4RodentMANHATTAN
5Noise - CommercialQUEENS
6Blocked DrivewayQUEENS
7Noise - CommercialQUEENS
8Noise - CommercialMANHATTAN
9Noise - CommercialBROOKLYN

10 rows × 2 columns

2.4 What’s the most common complaint type?

This is a really easy question to answer! There’s a .value_counts() method that we can use:

complaints['Complaint Type'].value_counts()

Output:

HEATING                     14200
GENERAL CONSTRUCTION         7471
Street Light Condition       7117
DOF Literature Request       5797
PLUMBING                     5373
PAINT - PLASTER              5149
Blocked Driveway             4590
NONCONST                     3998
Street Condition             3473
Illegal Parking              3343
Noise                        3321
Traffic Signal Condition     3145
Dirty Conditions             2653
Water System                 2636
Noise - Commercial           2578
...
Opinion for the Mayor                2
Window Guard                         2
DFTA Literature Request              2
Legal Services Provider Complaint    2
Open Flame Permit                    1
Snow                                 1
Municipal Parking Facility           1
X-Ray Machine/Equipment              1
Stalled Sites                        1
DHS Income Savings Requirement       1
Tunnel Condition                     1
Highway Sign - Damaged               1
Ferry Permit                         1
Trans Fat                            1
DWD                                  1
Length: 165, dtype: int64

If we just wanted the top 10 most common complaints, we can do this:

complaint_counts = complaints['Complaint Type'].value_counts()
complaint_counts[:10]

Output:

HEATING                   14200
GENERAL CONSTRUCTION       7471
Street Light Condition     7117
DOF Literature Request     5797
PLUMBING                   5373
PAINT - PLASTER            5149
Blocked Driveway           4590
NONCONST                   3998
Street Condition           3473
Illegal Parking            3343
dtype: int64

But it gets better! We can plot them!

complaint_counts[:10].plot(kind='bar')

Output:

Plotting complaints with Matplotlib

Help us improve this content by editing this page on GitHub