A practical introduction to IPython Notebook & pandas

Hi! I'm Julia.

Right now: Hacker School.
Before: Data scientist.

I'm on the internet at http://jvns.ca, http://twitter.com/b0rk

Follow along by downloading this presentation and running the code yourself:

Setup:

  • You can ask me any question, any time.
  • It's the end of the day
  • I'd rather cover less material and you have you understand more of it.
  • There will be exercises! Pair up with the person next to you and do the exercises.

In [1]:
%pylab inline
import pandas as pd
pd.set_option('display.mpl_style', 'default')
figsize(15, 6)
pd.set_option('display.line_width', 4000)
pd.set_option('display.max_columns', 100)


Populating the interactive namespace from numpy and matplotlib

Goal (in 6 months)

Know how to use IPython Notebook + pandas to answer your questions about data

  • How to start IPython Notebook
  • How to read data into pandas
  • How to do simple manipulations on pandas dataframes

Goal (Today)

Know how to use pandas to answer some specific questions about a dataset

Roadmap:

  1. Demo with rats
  2. Dataframes: what makes pandas powerful
  3. Selecting data from a dataframe
  4. Time series and indexes and resampling
  5. Groupby + aggregate

Some notes about installation:

Don't do this:

sudo apt-get install ipython-notebook

Instead, do this:

pip install ipython tornado pyzmq

or install Anaconda from http://store.continuum.io (what I do)

You can start IPython notebook by running

ipython notebook --pylab inline

First: Read the data


In [2]:
# Download and read the data
!wget "http://bit.ly/311-data-tar-gz"
!tar -xzf "311-data.tar.gz" # wget does different things
!tar -xzf "311-data-tar-gz" # wget does different things
orig_data = pd.read_csv('./311-service-requests.csv', nrows=100000, parse_dates=['Created Date'])


--2014-11-11 15:06:47--  http://bit.ly/311-data-tar-gz
Resolving bit.ly (bit.ly)... 69.58.188.40, 69.58.188.39
Connecting to bit.ly (bit.ly)|69.58.188.40|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://dl.dropboxusercontent.com/u/115162019/311-data.tar.gz [following]
--2014-11-11 15:06:48--  https://dl.dropboxusercontent.com/u/115162019/311-data.tar.gz
Resolving dl.dropboxusercontent.com (dl.dropboxusercontent.com)... 107.22.162.246, 54.225.159.160, 23.21.47.41, ...
Connecting to dl.dropboxusercontent.com (dl.dropboxusercontent.com)|107.22.162.246|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8492118 (8.1M) [application/octet-stream]
Saving to: ‘311-data-tar-gz’

100%[======================================>] 8,492,118    121KB/s   in 78s    

2014-11-11 15:08:08 (106 KB/s) - ‘311-data-tar-gz’ saved [8492118/8492118]

tar (child): 311-data.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
/usr/lib/python2.7/dist-packages/pandas/io/parsers.py:1070: DtypeWarning: Columns (8,47,48) have mixed types. Specify dtype option on import or set low_memory=False.
  data = self._reader.read(nrows)

In [3]:
plot(orig_data['Longitude'], orig_data['Latitude'], '.', color="purple")


Out[3]:
[<matplotlib.lines.Line2D at 0x7ff71a28f9d0>]

In [6]:
orig_data.columns


Out[6]:
Index([u'Unique Key', u'Created Date', u'Closed Date', u'Agency', u'Agency Name', u'Complaint Type', u'Descriptor', u'Location Type', u'Incident Zip', u'Incident Address', u'Street Name', u'Cross Street 1', u'Cross Street 2', u'Intersection Street 1', u'Intersection Street 2', u'Address Type', u'City', u'Landmark', u'Facility Type', u'Status', u'Due Date', u'Resolution Action Updated Date', u'Community Board', u'Borough', u'X Coordinate (State Plane)', u'Y Coordinate (State Plane)', u'Park Facility Name', u'Park Borough', u'School Name', u'School Number', u'School Region', u'School Code', u'School Phone Number', u'School Address', u'School City', u'School State', u'School Zip', u'School Not Found', u'School or Citywide Complaint', u'Vehicle Type', u'Taxi Company Borough', u'Taxi Pick Up Location', u'Bridge Highway Name', u'Bridge Highway Direction', u'Road Ramp', u'Bridge Highway Segment', u'Garage Lot Name', u'Ferry Direction', u'Ferry Terminal Name', u'Latitude', u'Longitude', u'Location'], dtype='object')

Example 1: Graph the number of noise complaints each hour in New York


In [8]:
complaints = orig_data[['Created Date', 'Complaint Type']]
noise_complaints = complaints[complaints['Complaint Type'] == 'Noise - Street/Sidewalk']
noise_complaints.set_index('Created Date').sort_index().resample('H', how=len).plot()


Out[8]:
<matplotlib.axes.AxesSubplot at 0x7ff71b8bd150>

Example 2: What are the most common complaint types?


In [4]:
orig_data['Complaint Type'].value_counts()[:20].plot(kind='bar')


Out[4]:
<matplotlib.axes.AxesSubplot at 0x4bc6e90>

Example 3: Does every zip code complain about the same things?


In [24]:
popular_zip_codes = orig_data['Incident Zip'].value_counts()[:10].index

zipcode_incident_table = orig_data.groupby(['Incident Zip', 'Complaint Type'])['Descriptor'].aggregate(len).unstack()
top_5_complaints=zipcode_incident_table.transpose()[popular_zip_codes]
top_5_complaints / top_5_complaints.sum()


Out[24]:
Incident Zip 11226 10467 10458 11233 11221 10468 11207 10457 10032 10031
Complaint Type
APPLIANCE 0.008157 0.002890 0.007455 0.010000 0.012361 0.008883 0.012739 0.002778 0.014144 0.002837
Adopt-A-Basket NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Air Quality 0.000816 0.000963 0.002130 NaN 0.001236 0.002538 NaN NaN NaN 0.001418
Animal Abuse NaN 0.003854 0.005325 NaN NaN 0.006345 NaN 0.001389 NaN NaN
Animal Facility - No Permit NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Animal in a Park 0.000816 0.001927 NaN NaN NaN NaN 0.001274 NaN NaN NaN
Asbestos NaN NaN NaN 0.001111 0.001236 0.001269 NaN NaN NaN 0.001418
BEST/Site Safety NaN NaN NaN NaN 0.001236 NaN 0.003822 0.002778 NaN NaN
Beach/Pool/Sauna Complaint NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Bike Rack Condition NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Bike/Roller/Skate Chronic NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Blocked Driveway 0.029364 0.028902 0.011715 0.023333 0.042027 0.015228 0.044586 0.018056 0.005658 0.002837
Boilers 0.001631 NaN NaN NaN 0.001236 0.001269 0.001274 NaN 0.001414 0.001418
Bridge Condition NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Broken Muni Meter 0.008157 0.003854 0.003195 NaN NaN 0.005076 NaN 0.001389 0.002829 0.001418
Building/Use 0.002447 0.011561 0.004260 0.005556 0.006180 0.003807 0.017834 0.002778 0.001414 0.002837
Bus Stop Shelter Placement NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
CONSTRUCTION 0.000816 0.001927 NaN 0.001111 0.006180 0.001269 0.002548 NaN 0.001414 0.001418
City Vehicle Placard Complaint NaN NaN NaN NaN NaN NaN 0.001274 NaN NaN 0.001418
Collection Truck Noise NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Construction NaN NaN 0.001065 NaN NaN NaN 0.001274 NaN NaN NaN
Consumer Complaint 0.004894 0.002890 0.013845 0.003333 0.003708 0.002538 0.010191 0.009722 0.001414 0.005674
Cranes and Derricks NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Curb Condition 0.000816 NaN NaN NaN NaN NaN NaN NaN NaN NaN
DOF Parking - Tax Exemption NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
DPR Internal NaN 0.002890 NaN NaN NaN 0.001269 NaN NaN NaN NaN
Damaged Tree 0.004078 0.000963 NaN 0.001111 0.006180 0.002538 0.011465 NaN NaN 0.002837
Dead Tree NaN 0.001927 NaN 0.002222 0.002472 0.001269 NaN NaN NaN 0.001418
Derelict Bicycle NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Derelict Vehicle 0.001631 0.002890 NaN 0.001111 0.006180 0.001269 0.001274 NaN NaN NaN
Derelict Vehicles 0.004894 0.000963 0.006390 0.006667 0.004944 NaN 0.020382 0.006944 NaN NaN
Dirty Conditions 0.016313 0.019268 0.017039 0.018889 0.022250 0.021574 0.024204 0.011111 NaN 0.008511
Disorderly Youth NaN NaN NaN NaN NaN NaN 0.001274 NaN 0.002829 NaN
Drinking NaN 0.000963 NaN NaN NaN 0.001269 0.001274 NaN NaN NaN
Drinking Water NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
EAP Inspection - F59 NaN 0.000963 NaN NaN NaN NaN NaN NaN NaN NaN
ELECTRIC 0.045677 0.043353 0.036209 0.081111 0.069221 0.029188 0.044586 0.038889 0.018388 0.043972
Electrical 0.000816 NaN NaN NaN 0.003708 NaN 0.002548 NaN NaN 0.001418
Elevator 0.007341 0.010597 0.002130 0.002222 NaN 0.001269 NaN 0.002778 0.009901 NaN
Fire Alarm - Modification NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Fire Alarm - New System NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Fire Alarm - Reinspection NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Fire Alarm - Replacement NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Fire Safety Director - F58 NaN NaN NaN NaN NaN NaN 0.002548 0.001389 NaN NaN
Food Establishment 0.003263 0.001927 0.002130 0.001111 0.002472 0.001269 0.002548 NaN 0.002829 0.001418
Food Poisoning NaN 0.002890 0.001065 NaN 0.002472 0.001269 NaN 0.001389 0.001414 0.001418
For Hire Vehicle Complaint 0.000816 0.001927 NaN NaN 0.001236 NaN 0.001274 NaN 0.005658 0.001418
Found Property NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
GENERAL CONSTRUCTION 0.144372 0.141618 0.137380 0.156667 0.144623 0.154822 0.117197 0.173611 0.151344 0.127660
General Construction/Plumbing 0.003263 0.003854 0.003195 0.004444 0.011125 NaN 0.005096 0.004167 0.002829 0.005674
Graffiti 0.014682 0.005780 0.008520 0.012222 0.003708 0.010152 0.008917 0.011111 0.001414 NaN
HEATING 0.240620 0.323699 0.351438 0.194444 0.177998 0.356599 0.165605 0.234722 0.267327 0.300709
Harboring Bees/Wasps NaN NaN NaN NaN NaN NaN 0.001274 NaN NaN NaN
Hazardous Materials NaN NaN 0.001065 NaN NaN NaN 0.001274 NaN NaN NaN
Highway Condition NaN NaN NaN NaN NaN NaN 0.001274 NaN NaN NaN
Highway Sign - Damaged NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Homeless Encampment 0.001631 NaN 0.001065 0.001111 0.002472 NaN NaN NaN NaN 0.001418
Homeless Person Assistance 0.000816 0.000963 0.001065 0.003333 NaN NaN NaN NaN NaN NaN
Illegal Animal Kept as Pet NaN NaN NaN NaN 0.001236 NaN NaN NaN NaN NaN
Illegal Animal Sold NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
... ... ... ... ... ... ... ... ... ...

141 rows × 10 columns


In [5]:
popular_zip_codes = orig_data['Incident Zip'].value_counts()[:10].index
zipcode_incident_table = orig_data.groupby(['Incident Zip', 'Complaint Type'])['Descriptor'].aggregate(len).unstack()
top_5_complaints = zipcode_incident_table.transpose()[popular_zip_codes]
normalized_complaints = top_5_complaints / top_5_complaints.sum()
normalized_complaints.dropna(how='any').sort('11226', ascending=False)[:5].transpose().plot(kind='bar')


Out[5]:
<matplotlib.axes.AxesSubplot at 0x32b5850>

Roadmap:

  1. Numpy: what makes pandas fast
  2. Dataframes: what makes pandas powerful
  3. Selecting data from a dataframe
  4. Time series and indexes
  5. Graphing

1. Numpy: What makes pandas fast


In [6]:
import numpy as np

How to create a numpy array


In [7]:
np.array([1,2,8.0, 3])


Out[7]:
array([ 1.,  2.,  8.,  3.])

In [8]:
np.arange(10)


Out[8]:
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])

In [9]:
# Generate random numbers
np.random.random(10)


Out[9]:
array([ 0.28288364,  0.82679209,  0.24453135,  0.1364644 ,  0.54386584,
        0.4973374 ,  0.47602631,  0.42742955,  0.57587563,  0.97857772])

How to operate on numpy arrays


In [10]:
prices = np.array([31, 40, 12, 40])
prices


Out[10]:
array([31, 40, 12, 40])

In [11]:
# Change the type
prices.astype(np.float32)


Out[11]:
array([ 31.,  40.,  12.,  40.], dtype=float32)

In [12]:
prices.astype(np.int64)


Out[12]:
array([31, 40, 12, 40])

In [13]:
# Find which ones are even
prices % 2 == 0


Out[13]:
array([False,  True,  True,  True], dtype=bool)

In [14]:
# Get only the even prices
prices[prices % 2 == 0]


Out[14]:
array([40, 12, 40])

More array operations


In [15]:
# Find the mean
np.mean(prices)


Out[15]:
30.75

In [16]:
prices * prices


Out[16]:
array([ 961, 1600,  144, 1600])

Vectorized operations: Don't do this:


In [17]:
v1 = np.array([1, 2, 3, 4, 5])
v2 = np.array([1, 2, 3, 8, 9])

In [18]:
result = np.zeros_like(v1)
for i in xrange(len(v1)):
    result[i] = 2 * v1[i] + 3 * v2[i]
print result


[ 5 10 15 32 37]

Do this instead:


In [19]:
result = 2 * v1 + 3 * v2
print result


[ 5 10 15 32 37]

Exercise 1: Compute the mean of the numbers 1-1000000

When you're done, try some harder things:

  • Generate some random numbers and find the mean or standard deviation.
  • play around some more with creating arrays

In [49]:
# Your code here
np.random.random(10)


Out[49]:
array([ 0.59989919,  0.57361888,  0.66982519,  0.93331083,  0.63191704,
        0.16494635,  0.22499443,  0.85554243,  0.8987145 ,  0.7257767 ])

In [54]:
ar = arange(1000000)
ar.mean()


Out[54]:
499999.5

Exercise 2: Find all the elements in the prices array that are divisible by 6

When you're done:

  • find all the cubes less than 10000

In [46]:
# Your code here
prices = np.array([31, 40, 12, 40])
prices[prices % 6 == 0]


Out[46]:
array([12])

In [21]:

What is pandas?

A few awesome things about pandas

  • Really, really, really, really good at time series
  • Can import Excel files (!!!)
  • Fast (joining dataframes, etc.)

This is what lets you manipulate data easily -- the dataframe is basically the whole reason for pandas. It's a powerful concept from the statistical computing language R.

If you don't know R, you can think of it like a database table (it has rows and columns), or like a table of numbers.

2. Dataframes: what makes pandas powerful


In [22]:
people = pd.read_csv('tiny.csv')
people


Out[22]:
name age height
0 Scott 12 61
1 Lea 13 73
2 Julia 14 66
3 Kate 15 62
4 Rishi 18 70

This is a like a SQL database, or an R dataframe. There are 3 columns, called 'name', 'age', and 'height, and 6 rows.

3. Selecting data from a dataframe

I want you to know about this because you almost always only want a subset of the data you're working on. We are going to look at a CSV with 40 columns and 1,000,000 rows.


In [25]:
# Load the first 5 rows of our CSV
small_requests = pd.read_csv('./311-service-requests.csv', nrows=5)

In [26]:
# How to get a column
small_requests['Complaint Type']


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

In [27]:
# How to get a subset of the columns
small_requests[['Complaint Type', 'Created Date']]


Out[27]:
Complaint Type Created Date
0 Noise - Street/Sidewalk 10/31/2013 02:08:41 AM
1 Illegal Parking 10/31/2013 02:01:04 AM
2 Noise - Commercial 10/31/2013 02:00:24 AM
3 Noise - Vehicle 10/31/2013 01:56:23 AM
4 Rodent 10/31/2013 01:53:44 AM

5 rows × 2 columns


In [29]:
# How to get 3 rows
small_requests[:3]


Out[29]:
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
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 197389 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)
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 201984 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)
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 246531 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)

3 rows × 52 columns

Get the first 3 rows of a column


In [30]:
small_requests['Agency Name'][:3]


Out[30]:
0    New York City Police Department
1    New York City Police Department
2    New York City Police Department
Name: Agency Name, dtype: object

In [31]:
small_requests[:3]['Agency Name']


Out[31]:
0    New York City Police Department
1    New York City Police Department
2    New York City Police Department
Name: Agency Name, dtype: object

Compare a column to a value


In [29]:
small_requests['Complaint Type']


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

In [30]:
# This is like our numpy example from before
small_requests['Complaint Type'] == 'Noise - Street/Sidewalk'


Out[30]:
0     True
1    False
2    False
3    False
4    False
Name: Complaint Type, dtype: bool

That's numpy in action! Using == on a column of a dataframe gives us a series of True and False values

Selecting only the rows with noise complaints


In [31]:
# This is like our numpy example earlier
noise_complaints = small_requests[small_requests['Complaint Type'] == 'Noise - Street/Sidewalk']
noise_complaints


Out[31]:
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
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 197389 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)

Any Dataframe has an index, which is a integer or date or something else associated to each row.


In [32]:
# How to get a specific row
small_requests.ix[0]


Out[32]:
Unique Key                                                       26589651
Created Date                                       10/31/2013 02:08:41 AM
Closed Date                                                           NaN
Agency                                                               NYPD
Agency Name                               New York City Police Department
Complaint Type                                    Noise - Street/Sidewalk
Descriptor                                                   Loud Talking
Location Type                                             Street/Sidewalk
Incident Zip                                                        11432
Incident Address                                         90-03 169 STREET
Street Name                                                    169 STREET
Cross Street 1                                                  90 AVENUE
Cross Street 2                                                  91 AVENUE
Intersection Street 1                                                 NaN
Intersection Street 2                                                 NaN
Address Type                                                      ADDRESS
City                                                              JAMAICA
Landmark                                                              NaN
Facility Type                                                    Precinct
Status                                                           Assigned
Due Date                                           10/31/2013 10:08:41 AM
Resolution Action Updated Date                     10/31/2013 02:35:17 AM
Community Board                                                 12 QUEENS
Borough                                                            QUEENS
X Coordinate (State Plane)                                        1042027
Y Coordinate (State Plane)                                         197389
Park Facility Name                                            Unspecified
Park Borough                                                       QUEENS
School Name                                                   Unspecified
School Number                                                 Unspecified
School Region                                                 Unspecified
School Code                                                   Unspecified
School Phone Number                                           Unspecified
School Address                                                Unspecified
School City                                                   Unspecified
School State                                                  Unspecified
School Zip                                                    Unspecified
School Not Found                                                        N
School or Citywide Complaint                                          NaN
Vehicle Type                                                          NaN
Taxi Company Borough                                                  NaN
Taxi Pick Up Location                                                 NaN
Bridge Highway Name                                                   NaN
Bridge Highway Direction                                              NaN
Road Ramp                                                             NaN
Bridge Highway Segment                                                NaN
Garage Lot Name                                                       NaN
Ferry Direction                                                       NaN
Ferry Terminal Name                                                   NaN
Latitude                                                         40.70828
Longitude                                                        -73.7916
Location                          (40.70827532593202, -73.79160395779721)
Name: 0, Length: 52, dtype: object

Exercise 2: Selecting things from dataframes

  • Select all the people with even ages from people
  • Find out how complaints were filed with the NYPD
  • The zip code here is 10007. How many complaints were filed here?
  • Find out which values the Descriptor column can have when the Complaint Type is "Noise - Street/Sidewalk"

In [39]:
# Your code here
all_requests = pd.read_csv('./311-service-requests.csv')
zip_complaints = all_requests[all_requests['Incident Zip'] == 10007]
zip_complaints


/usr/lib/python2.7/dist-packages/pandas/io/parsers.py:1070: DtypeWarning: Columns (8) have mixed types. Specify dtype option on import or set low_memory=False.
  data = self._reader.read(nrows)
Out[39]:
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
73 26595413 10/30/2013 11:53:00 PM NaN DEP Department of Environmental Protection Noise Noise: Construction Before/After Hours (NM1) NaN 10007 NaN NaN NaN NaN CHAMBERS STREET WEST BROADWAY INTERSECTION NEW YORK NaN NaN Open NaN NaN 01 MANHATTAN MANHATTAN 981689 199960 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.715520 -74.009238 (40.71552037648501, -74.0092382743091)
996 26594761 10/30/2013 04:07:50 PM NaN DOHMH Department of Health and Mental Hygiene Smoking Smoking Violation Commercial Building 10007 225 BROADWAY BROADWAY ANN STREET BARCLAY STREET NaN NaN ADDRESS NEW YORK NaN NaN Assigned 12/06/2013 04:07:50 PM 10/30/2013 04:24:25 PM 01 MANHATTAN MANHATTAN 981972 198630 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.711870 -74.008217 (40.71186992119673, -74.0082169606923)
1426 26594067 10/30/2013 02:21:00 PM NaN DEP Department of Environmental Protection Water System Other Water Problem (Use Comments) (WZZ) NaN 10007 90 WEST BROADWAY WEST BROADWAY WARREN STREET CHAMBERS STREET NaN NaN ADDRESS NEW YORK NaN NaN Open NaN NaN 01 MANHATTAN MANHATTAN 981634 199872 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.715279 -74.009437 (40.715278821443526, -74.00943664115954)
1433 26594925 10/30/2013 02:20:00 PM NaN DEP Department of Environmental Protection Water System Leak (Use Comments) (WA2) NaN 10007 75 MURRAY STREET MURRAY STREET WEST BROADWAY GREENWICH STREET NaN NaN ADDRESS NEW YORK NaN NaN Open NaN NaN 01 MANHATTAN MANHATTAN 981285 199638 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.714636 -74.010695 (40.714636437303575, -74.01069547836116)
2075 26590179 10/30/2013 11:36:53 AM 10/30/2013 03:22:01 PM NYPD New York City Police Department Noise - Park Loud Music/Party Park/Playground 10007 31 CHAMBERS STREET CHAMBERS STREET CENTRE STREET ELK STREET NaN NaN ADDRESS NEW YORK NaN Precinct Closed 10/30/2013 07:36:53 PM 10/30/2013 03:22:01 PM 01 MANHATTAN MANHATTAN 982965 199188 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.713402 -74.004635 (40.7134016982292, -74.00463522262078)
2462 26591224 10/30/2013 10:20:24 AM 10/30/2013 10:20:24 AM DOB Department of Buildings Cranes and Derricks Crane/Suspension Scaffold - No Permit/License/... NaN 10007 95 CHURCH STREET CHURCH STREET BARCLAY STREET PARK PLACE NaN NaN ADDRESS NEW YORK NaN NaN Closed NaN 10/30/2013 12:00:00 AM 01 MANHATTAN MANHATTAN 981590 198969 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.712800 -74.009595 (40.71280028888276, -74.00959500462456)
2793 26594904 10/30/2013 09:32:00 AM 10/30/2013 12:00:00 PM DSNY BCC - Manhattan Other Enforcement E10 Obstruction (Street/Sidewalk) Sidewalk 10007 96 CHAMBERS STREET CHAMBERS STREET BROADWAY CHURCH STREET NaN NaN ADDRESS NEW YORK NaN DSNY Garage Closed NaN 10/30/2013 12:00:00 PM 01 MANHATTAN MANHATTAN 982190 199654 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.714681 -74.007431 (40.7146806104873, -74.00743092748652)
3103 26592808 10/30/2013 07:29:59 AM 10/30/2013 08:23:25 AM NYPD New York City Police Department Illegal Parking Blocked Sidewalk Street/Sidewalk 10007 NaN NaN NaN NaN WARREN STREET CHURCH STREET INTERSECTION NEW YORK NaN Precinct Closed 10/30/2013 03:29:59 PM 10/30/2013 08:23:25 AM 01 MANHATTAN MANHATTAN 981925 199538 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.714362 -74.008387 (40.71436215252671, -74.00838680770177)
6004 26587054 10/29/2013 04:50:53 PM NaN DPR Department of Parks and Recreation Maintenance or Facility Structure - Outdoors Park 10007 NaN NaN NaN NaN NaN NaN NaN NEW YORK NaN NaN Assigned 11/12/2013 04:50:53 PM NaN 01 MANHATTAN MANHATTAN NaN NaN City Hall Park MANHATTAN City Hall Park M013 NaN NaN 2124080100 Broadway, Park Row and Chambers Street NEW YORK NY 10007 N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
6416 26586133 10/29/2013 03:19:39 PM 10/30/2013 05:29:08 PM FDNY Bureau of Fire Prevention - Highrise Unit - In... Fire Safety Director - F58 On Site Test Street Address 10007 90 CHURCH STREET CHURCH STREET VESEY STREET BARCLAY STREET NaN NaN ADDRESS NEW YORK NaN NaN Closed 11/03/2013 03:19:39 PM 10/30/2013 05:29:08 PM 01 MANHATTAN MANHATTAN 981540 198891 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.712586 -74.009775 (40.712586182290615, -74.00977533045506)
6912 26585075 10/29/2013 01:41:43 PM 10/30/2013 03:46:38 PM FDNY Bureau of Fire Prevention - Highrise Unit - In... Fire Safety Director - F58 On Site Test Street Address 10007 26 FEDERAL PLAZA FEDERAL PLAZA THOMAS STREET WORTH STREET NaN NaN ADDRESS NEW YORK NaN NaN Closed 11/03/2013 01:41:43 PM 10/30/2013 03:46:38 PM 01 MANHATTAN MANHATTAN 982935 200140 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.716015 -74.004744 (40.716014706345376, -74.00474362389673)
7010 26588179 10/29/2013 01:14:31 PM 10/30/2013 12:00:00 AM DOB Department of Buildings General Construction/Plumbing Building Shaking/Vibrating/Structural Stability NaN 10007 18 MURRAY STREET MURRAY STREET BROADWAY CHURCH STREET NaN NaN ADDRESS NEW YORK NaN NaN Assigned NaN 10/30/2013 12:00:00 AM 01 MANHATTAN MANHATTAN 982012 199201 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.713437 -74.008073 (40.71343719038962, -74.0080728667385)
7014 26587180 10/29/2013 01:11:18 PM NaN DOB Department of Buildings Elevator Elevator - Defective/Not Working NaN 10007 18 MURRAY STREET MURRAY STREET BROADWAY CHURCH STREET NaN NaN ADDRESS NEW YORK NaN NaN Open NaN NaN 01 MANHATTAN MANHATTAN 982012 199201 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.713437 -74.008073 (40.71343719038962, -74.0080728667385)
7330 26582512 10/29/2013 11:53:00 AM 10/29/2013 12:00:00 PM DSNY BCC - Manhattan Overflowing Litter Baskets 6 Overflowing Litter Baskets Sidewalk 10007 NaN NaN NaN NaN CENTRE STREET DUANE STREET INTERSECTION NEW YORK NaN DSNY Garage Closed NaN 10/29/2013 12:00:00 PM 01 MANHATTAN MANHATTAN 983392 199391 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.713959 -74.003095 (40.71395893651303, -74.00309498385707)
7369 26585533 10/29/2013 11:43:00 AM 10/29/2013 12:00:00 PM DSNY BCC - Manhattan Litter Basket / Request 10 Litter Basket / Request Sidewalk 10007 NaN NaN NaN NaN CENTRE STREET DUANE STREET INTERSECTION NEW YORK NaN DSNY Garage Closed NaN 10/29/2013 12:00:00 PM 01 MANHATTAN MANHATTAN 983392 199391 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.713959 -74.003095 (40.71395893651303, -74.00309498385707)
8005 26585001 10/29/2013 09:49:05 AM 10/29/2013 03:12:22 PM NYPD New York City Police Department Illegal Parking Blocked Sidewalk Street/Sidewalk 10007 46 WARREN STREET WARREN STREET CHURCH STREET WEST BROADWAY NaN NaN ADDRESS NEW YORK NaN Precinct Closed 10/29/2013 05:49:05 PM 10/29/2013 03:12:22 PM 01 MANHATTAN MANHATTAN 981783 199626 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.714604 -74.008899 (40.71460365304999, -74.00889906648182)
8461 26584888 10/29/2013 06:32:45 AM 10/29/2013 07:32:56 AM NYPD New York City Police Department Illegal Parking Posted Parking Sign Violation Street/Sidewalk 10007 NaN NaN NaN NaN CORTLANDT STREET BROADWAY INTERSECTION NEW YORK NaN Precinct Closed 10/29/2013 02:32:45 PM 10/29/2013 07:32:56 AM 01 MANHATTAN MANHATTAN 981481 197878 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.709806 -74.009988 (40.709805719796464, -74.009987734673)
11343 26576588 10/28/2013 09:48:55 PM NaN DOHMH Department of Health and Mental Hygiene Food Establishment Kitchen/Food Prep Area Restaurant/Bar/Deli/Bakery 10007 73 WARREN STREET WARREN STREET WEST BROADWAY GREENWICH STREET NaN NaN ADDRESS NEW YORK NaN NaN Assigned 12/27/2013 09:48:55 PM 10/30/2013 04:17:05 PM 01 MANHATTAN MANHATTAN 981431 199828 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.715158 -74.010169 (40.715157989612656, -74.01016890031018)
12514 26574275 10/28/2013 02:38:00 PM 10/28/2013 04:30:00 PM DOT Department of Transportation Traffic Signal Condition Controller NaN 10007 NaN NaN NaN NaN BROADWAY DUANE STREET INTERSECTION NEW YORK NaN NaN Closed NaN 10/28/2013 04:30:00 PM 01 MANHATTAN MANHATTAN 982748 199856 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.715235 -74.005418 (40.71523516452979, -74.00541812909766)
12518 26575202 10/28/2013 02:37:00 PM 10/28/2013 04:41:00 PM DOT Department of Transportation Traffic Signal Condition Controller NaN 10007 NaN NaN NaN NaN BROADWAY WARREN STREET INTERSECTION NEW YORK NaN NaN Closed NaN 10/28/2013 04:41:00 PM 01 MANHATTAN MANHATTAN 982378 199267 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.713618 -74.006753 (40.71361842965829, -74.00675265756045)
12686 26580575 10/28/2013 02:05:47 PM 10/29/2013 11:19:58 AM DOF Personal Exemption Unit DOF Parking - Tax Exemption Tax Exemption Address 10007 105 DUANE STREET DUANE STREET BROADWAY TRIMBLE PLACE NaN NaN ADDRESS NEW YORK NaN NaN Closed 11/02/2013 02:05:47 PM 10/29/2013 11:19:58 AM 01 MANHATTAN MANHATTAN 982569 199967 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.715540 -74.006064 (40.715539800779354, -74.00606385928269)
13134 26576782 10/28/2013 11:56:55 AM 10/28/2013 11:56:55 AM DOB Department of Buildings Cranes and Derricks Crane/Suspension Scaffold - No Permit/License/... NaN 10007 99 CHURCH STREET CHURCH STREET BARCLAY STREET PARK PLACE NaN NaN ADDRESS NEW YORK NaN NaN Closed NaN 10/28/2013 12:00:00 AM 01 MANHATTAN MANHATTAN 981622 199023 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.712949 -74.009480 (40.71294851557799, -74.00947959707774)
13191 26576669 10/28/2013 11:49:00 AM NaN DEP Department of Environmental Protection Noise Noise: Construction Before/After Hours (NM1) NaN 10007 10 BARCLAY STREET BARCLAY STREET BROADWAY CHURCH STREET NaN NaN ADDRESS NEW YORK NaN NaN Open NaN NaN 01 MANHATTAN MANHATTAN 981876 198750 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.712199 -74.008563 (40.71219926740093, -74.0085632840522)
16152 26579697 10/28/2013 12:00:00 AM NaN HPD Department of Housing Preservation and Develop... HEATING HEAT RESIDENTIAL BUILDING 10007 118 DUANE STREET DUANE STREET TRIMBLE PLACE CHURCH STREET NaN NaN ADDRESS NEW YORK NaN NaN Open NaN 10/28/2013 12:00:00 AM 01 MANHATTAN MANHATTAN 982381 200072 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.715828 -74.006742 (40.71582796293405, -74.00674205948847)
49790 26525260 10/21/2013 12:00:00 AM NaN DOHMH Department of Health and Mental Hygiene Rodent Rat Sighting Public Garden 10007 NaN NaN NaN NaN WEST BROADWAY CHAMBERS STREET INTERSECTION NEW YORK NaN NaN Assigned 11/20/2013 06:36:15 PM 10/21/2013 06:39:56 PM 01 MANHATTAN MANHATTAN 981689 199960 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.715520 -74.009238 (40.71552037648501, -74.0092382743091)
50592 26522442 10/21/2013 12:00:00 AM NaN DOHMH Department of Health and Mental Hygiene Rodent Condition Attracting Rodents Construction Site 10007 NaN NaN NaN NaN CHAMBERS STREET HUDSON STREET INTERSECTION NEW YORK NaN NaN Assigned 11/20/2013 07:02:31 PM 10/21/2013 07:06:08 PM 01 MANHATTAN MANHATTAN 981689 199960 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.715520 -74.009238 (40.71552037648501, -74.0092382743091)
50635 26523736 10/21/2013 12:00:00 AM NaN DOHMH Department of Health and Mental Hygiene Rodent Rat Sighting 3+ Family Mixed Use Building 10007 17 PARK PLACE PARK PLACE BROADWAY CHURCH STREET NaN NaN ADDRESS NEW YORK NaN NaN Assigned 11/20/2013 05:15:01 PM 10/21/2013 05:16:58 PM 01 MANHATTAN MANHATTAN 981884 199018 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.712935 -74.008535 (40.71293486571282, -74.00853452134116)
51298 26523882 10/21/2013 12:00:00 AM NaN DOHMH Department of Health and Mental Hygiene Rodent Rat Sighting Public Garden 10007 NaN NaN NaN NaN CHAMBERS STREET HUDSON STREET INTERSECTION NEW YORK NaN NaN Assigned 11/20/2013 08:29:49 PM 10/21/2013 08:32:52 PM 01 MANHATTAN MANHATTAN 981689 199960 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.715520 -74.009238 (40.71552037648501, -74.0092382743091)
51641 26518930 10/20/2013 07:14:26 PM NaN TLC Taxi and Limousine Commission Taxi Complaint Driver Complaint NaN 10007 24 CHURCH STREET CHURCH STREET CORTLANDT STREET DEY STREET NaN NaN ADDRESS NEW YORK NaN NaN Assigned 12/05/2013 09:40:13 AM 10/21/2013 09:42:15 AM 01 MANHATTAN MANHATTAN 981170 198156 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN Other NaN NaN NaN NaN NaN NaN NaN 40.710569 -74.011110 (40.71056866102571, -74.01110963340768)
52486 26518706 10/20/2013 02:44:08 AM NaN TLC Taxi and Limousine Commission Taxi Complaint Driver Complaint Street 10007 NaN NaN NaN NaN MURRAY STREET WEST BROADWAY INTERSECTION NEW YORK NaN NaN Assigned 12/05/2013 09:40:11 AM 10/21/2013 09:41:19 AM 01 MANHATTAN MANHATTAN 981442 199546 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN Intersection NaN NaN NaN NaN NaN NaN NaN 40.714384 -74.010129 (40.71438397050371, -74.01012910268898)
54459 26515739 10/19/2013 12:33:00 PM NaN DEP Department of Environmental Protection Noise Noise: Construction Before/After Hours (NM1) NaN 10007 NaN NaN NaN NaN BARCLAY STREET CHURCH STREET INTERSECTION NEW YORK NaN NaN Open NaN NaN 01 MANHATTAN MANHATTAN 981570 198941 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.712723 -74.009667 (40.712723429518185, -74.00966713636964)
54468 26514481 10/19/2013 12:29:00 PM NaN DEP Department of Environmental Protection Noise Noise: Jack Hammering (NC2) NaN 10007 30 PARK PLACE PARK PLACE BROADWAY CHURCH STREET NaN NaN ADDRESS NEW YORK NaN NaN Open NaN NaN 01 MANHATTAN MANHATTAN 981842 199037 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.712987 -74.008686 (40.71298700485343, -74.00868602851494)
54704 26516903 10/19/2013 10:09:00 AM NaN DEP Department of Environmental Protection Noise Noise: Construction Before/After Hours (NM1) NaN 10007 CHURCH STREET CHURCH STREET BARCLAY STREET PARK PLACE NaN NaN BLOCKFACE NEW YORK NaN NaN Open NaN NaN 01 MANHATTAN MANHATTAN 981627 199038 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.712990 -74.009462 (40.71298968848687, -74.00946156715904)
54764 26515085 10/19/2013 09:37:31 AM 10/19/2013 02:51:44 PM NYPD New York City Police Department Noise - Vehicle Engine Idling Street/Sidewalk 10007 CHURCH STREET CHURCH STREET BARCLAY STREET PARK PLACE NaN NaN BLOCKFACE NEW YORK NaN Precinct Closed 10/19/2013 05:37:31 PM 10/19/2013 02:51:44 PM 01 MANHATTAN MANHATTAN 981627 199038 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.712990 -74.009462 (40.71298968848687, -74.00946156715904)
54819 26516202 10/19/2013 09:08:00 AM 10/19/2013 10:05:00 AM DOT Department of Transportation Traffic Signal Condition Controller NaN 10007 NaN NaN NaN NaN BROADWAY WARREN STREET INTERSECTION NEW YORK NaN NaN Closed NaN 10/19/2013 10:05:00 AM 01 MANHATTAN MANHATTAN 982378 199267 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.713618 -74.006753 (40.71361842965829, -74.00675265756045)
54863 26526666 10/19/2013 08:43:00 AM NaN DSNY A - Illegal Posting Manhattan and Bronx Dirty Conditions E15 Illegal Postering Sidewalk 10007 WEST BROADWAY WEST BROADWAY CHAMBERS STREET WARREN STREET NaN NaN BLOCKFACE NEW YORK NaN NaN Open NaN NaN 01 MANHATTAN MANHATTAN 981627 199855 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.715232 -74.009462 (40.71523215843662, -74.00946188548653)
54926 26514339 10/19/2013 08:03:28 AM 10/19/2013 03:14:55 PM NYPD New York City Police Department Illegal Parking Posted Parking Sign Violation Street/Sidewalk 10007 NaN NaN NaN NaN CHAMBERS STREET WEST STREET INTERSECTION NEW YORK NaN Precinct Closed 10/19/2013 04:03:28 PM 10/19/2013 03:14:55 PM 01 MANHATTAN MANHATTAN 980683 200563 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.717175 -74.012868 (40.71717511862166, -74.01286752934263)
55235 26517239 10/19/2013 12:32:00 AM 10/23/2013 12:00:00 PM DSNY A - Manhattan Dirty Conditions E3 Dirty Sidewalk Sidewalk 10007 24 MURRAY STREET MURRAY STREET BROADWAY CHURCH STREET NaN NaN ADDRESS NEW YORK NaN NaN Closed NaN 10/23/2013 12:00:00 PM 01 MANHATTAN MANHATTAN 981950 199239 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.713541 -74.008297 (40.71354147542584, -74.00829652482142)
55254 26509986 10/19/2013 12:14:48 AM 10/30/2013 02:04:24 PM DOT Department of Transportation Sidewalk Condition Blocked - Construction Sidewalk 10007 12 MURRAY STREET MURRAY STREET BROADWAY CHURCH STREET NaN NaN ADDRESS NEW YORK NaN NaN Closed 10/31/2013 09:00:01 AM 10/30/2013 02:03:33 PM 01 MANHATTAN MANHATTAN 982075 199163 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.713333 -74.007846 (40.71333290516334, -74.00784560218203)
55263 26513849 10/19/2013 12:09:02 AM 10/30/2013 02:04:24 PM DOT Department of Transportation Sidewalk Condition Blocked - Construction Sidewalk 10007 12 MURRAY STREET MURRAY STREET BROADWAY CHURCH STREET NaN NaN ADDRESS NEW YORK NaN NaN Closed 10/31/2013 09:00:01 AM 10/30/2013 02:04:24 PM 01 MANHATTAN MANHATTAN 982075 199163 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.713333 -74.007846 (40.71333290516334, -74.00784560218203)
56698 26509904 10/18/2013 04:55:55 PM 10/21/2013 09:03:27 AM DOT Department of Transportation Broken Muni Meter No Receipt Street 10007 86 WEST BROADWAY WEST BROADWAY WARREN STREET CHAMBERS STREET NaN NaN ADDRESS NEW YORK NaN NaN Closed 11/08/2013 04:55:55 PM 10/21/2013 09:03:27 AM 01 MANHATTAN MANHATTAN 981616 199843 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.715199 -74.009502 (40.71519921803826, -74.00950156082915)
57122 26510890 10/18/2013 02:56:00 PM 10/18/2013 04:50:00 PM DOT Department of Transportation Traffic Signal Condition LED Lense NaN 10007 NaN NaN NaN NaN WEST STREET MURRAY STREET INTERSECTION NEW YORK NaN NaN Closed NaN 10/18/2013 04:50:00 PM 01 MANHATTAN MANHATTAN 980549 199856 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.715235 -74.013351 (40.71523451791951, -74.01335052973418)
57198 26509083 10/18/2013 02:34:00 PM 10/18/2013 02:34:00 PM DOT Department of Transportation Street Light Condition Street Light Out NaN 10007 NaN NaN NaN NaN BROADWAY THOMAS STREET INTERSECTION NEW YORK NaN NaN Closed NaN 10/17/2013 11:20:00 PM 01 MANHATTAN MANHATTAN 982871 200047 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.715759 -74.004974 (40.71575943386308, -74.00497447323234)
58147 26508396 10/18/2013 10:38:40 AM NaN DOHMH Department of Health and Mental Hygiene Food Poisoning 1 or 2 Restaurant/Bar/Deli/Bakery 10007 189 CHURCH STREET CHURCH STREET READE STREET DUANE STREET NaN NaN ADDRESS NEW YORK NaN NaN Open 12/02/2013 10:38:40 AM 10/21/2013 11:10:01 AM 01 MANHATTAN MANHATTAN 982267 200101 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.715908 -74.007153 (40.71590753617471, -74.00715330119243)
58592 26510627 10/18/2013 08:24:00 AM 10/18/2013 10:50:00 PM DOT Department of Transportation Street Light Condition Street Light Out NaN 10007 NaN NaN NaN NaN BROADWAY PARK ROW INTERSECTION NEW YORK NaN NaN Closed NaN 10/18/2013 10:50:00 PM Unspecified MANHATTAN MANHATTAN 982501 199466 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.714165 -74.006309 (40.71416466233701, -74.0063090250317)
61054 26501956 10/17/2013 04:27:27 PM 10/25/2013 03:58:45 PM DOT Department of Transportation Broken Muni Meter Coin or Card Did Not Register Street 10007 NaN NaN NaN NaN WEST BROADWAY MURRAY STREET INTERSECTION NEW YORK NaN NaN Closed 11/06/2013 04:27:27 PM 10/25/2013 03:58:45 PM 01 MANHATTAN MANHATTAN 981442 199546 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.714384 -74.010129 (40.71438397050371, -74.01012910268898)
61880 26500715 10/17/2013 01:09:49 PM 10/25/2013 06:47:59 PM DOT Department of Transportation Broken Muni Meter No Receipt Street 10007 NaN NaN NaN NaN WEST BROADWAY MURRAY STREET INTERSECTION NEW YORK NaN NaN Closed 11/07/2013 01:09:49 PM 10/25/2013 06:47:59 PM 01 MANHATTAN MANHATTAN 981442 199546 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.714384 -74.010129 (40.71438397050371, -74.01012910268898)
62401 26505297 10/17/2013 11:07:52 AM 10/23/2013 10:07:04 AM DPR Department of Parks and Recreation Maintenance or Facility Rodent Sighting Park 10007 NaN NaN NaN NaN NaN NaN NaN NEW YORK NaN NaN Closed 10/27/2013 11:07:52 AM 10/23/2013 10:07:04 AM Unspecified MANHATTAN MANHATTAN NaN NaN James Madison Plaza MANHATTAN James Madison Plaza M255 NaN NaN NA 0/0 Pearl Street between Madison Street and James ... NEW YORK NY 10007 N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
62730 26501462 10/17/2013 09:46:58 AM 10/22/2013 01:57:32 PM DPR Department of Parks and Recreation Maintenance or Facility Hours of Operation Park 10007 NaN NaN NaN NaN BROADWAY MURRAY STREET INTERSECTION NEW YORK NaN NaN Closed 10/20/2013 09:46:58 AM 10/22/2013 01:57:32 PM 01 MANHATTAN MANHATTAN 982247 199062 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.713056 -74.007225 (40.7130557248531, -74.00722513830726)
62901 26502550 10/17/2013 08:55:22 AM 10/17/2013 10:06:45 AM NYPD New York City Police Department Illegal Parking Double Parked Blocking Vehicle Street/Sidewalk 10007 24 WARREN STREET WARREN STREET BROADWAY CHURCH STREET NaN NaN ADDRESS NEW YORK NaN Precinct Closed 10/17/2013 04:55:22 PM 10/17/2013 10:06:45 AM 01 MANHATTAN MANHATTAN 982094 199441 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.714096 -74.007777 (40.71409595348573, -74.00777715491866)
64812 26494823 10/16/2013 10:11:16 PM 10/16/2013 11:27:59 PM NYPD New York City Police Department Illegal Parking Posted Parking Sign Violation Street/Sidewalk 10007 90 W BROADWAY W BROADWAY NaN NaN NaN NaN LATLONG NEW YORK NaN Precinct Closed 10/17/2013 06:11:16 AM 10/16/2013 11:28:00 PM 01 MANHATTAN MANHATTAN 981593 199952 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.715498 -74.009585 (40.71549839008896, -74.00958457116195)
64851 26496545 10/16/2013 09:37:32 PM 10/18/2013 10:34:52 AM DPR Department of Parks and Recreation Violation of Park Rules Obstructing Public Use Park 10007 NaN NaN NaN NaN NaN NaN NaN NEW YORK NaN NaN Closed 10/30/2013 09:37:32 PM 10/18/2013 10:34:52 AM Unspecified MANHATTAN MANHATTAN NaN NaN Vietnam Veterans Plaza MANHATTAN Vietnam Veterans Plaza M046 NaN NaN NA 0/0 South Street between Broad Street and Old Slip NEW YORK NY 10007 N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
64888 26493479 10/16/2013 09:11:50 PM 10/16/2013 11:07:36 PM NYPD New York City Police Department Illegal Parking Posted Parking Sign Violation Street/Sidewalk 10007 81-99 W BROADWAY W BROADWAY NaN NaN NaN NaN LATLONG NEW YORK NaN Precinct Closed 10/17/2013 05:11:50 AM 10/16/2013 11:07:36 PM 01 MANHATTAN MANHATTAN 981625 199844 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.715202 -74.009469 (40.715201965474016, -74.00946909574955)
99087 26452722 10/07/2013 05:07:00 PM NaN DEP Department of Environmental Protection Air Quality Air: Odor/Fumes, Restaurant (AD2) NaN 10007 69 READE STREET READE STREET BROADWAY CHURCH STREET NaN NaN ADDRESS NEW YORK NaN NaN Open NaN NaN 01 MANHATTAN MANHATTAN 982378 199794 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.715065 -74.006753 (40.715064918802476, -74.0067528041062)
99104 26451762 10/07/2013 05:03:00 PM NaN DSNY A - Manhattan Dirty Conditions E3 Dirty Sidewalk Sidewalk 10007 69 READE STREET READE STREET BROADWAY CHURCH STREET NaN NaN ADDRESS NEW YORK NaN NaN Open NaN NaN 01 MANHATTAN MANHATTAN 982378 199794 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.715065 -74.006753 (40.715064918802476, -74.0067528041062)
99686 26447696 10/07/2013 03:04:58 PM NaN DOHMH Department of Health and Mental Hygiene Indoor Air Quality Chemical Vapors/Gases/Odors 3+ Family Apartment Building 10007 25 MURRAY STREET MURRAY STREET BROADWAY CHURCH STREET NaN NaN ADDRESS NEW YORK NaN NaN Open 11/06/2013 03:04:58 PM NaN 01 MANHATTAN MANHATTAN 981932 199256 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.713588 -74.008361 (40.71358813167309, -74.00836145999914)
99848 26453113 10/07/2013 02:33:07 PM NaN DOHMH Department of Health and Mental Hygiene Food Establishment Toilet Facility Restaurant/Bar/Deli/Bakery 10007 167 CHAMBERS STREET CHAMBERS STREET HUDSON STREET GREENWICH STREET NaN NaN ADDRESS NEW YORK NaN NaN Assigned 12/06/2013 02:33:07 PM 10/08/2013 03:53:11 PM 01 MANHATTAN MANHATTAN 981304 200193 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.716160 -74.010627 (40.716159785887584, -74.01062718360902)
100147 26452030 10/07/2013 01:22:27 PM NaN DOT Department of Transportation Broken Muni Meter No Receipt Street 10007 NaN NaN NaN NaN BROADWAY BARCLAY STREET INTERSECTION NEW YORK NaN NaN Assigned 10/28/2013 01:22:27 PM NaN 01 MANHATTAN MANHATTAN 982004 198675 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified N NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.711993 -74.008102 (40.71199344367041, -74.00810154868941)
102168 26448965 10/07/2013 12:00:00 AM NaN HPD Department of Housing Preservation and Develop... PLUMBING SEWER RESIDENTIAL BUILDING 10007 311 BROADWAY BROADWAY DUANE STREET THOMAS STREET NaN NaN ADDRESS NEW YORK NaN NaN Open NaN 10/07/2013 12:00:00 AM 01 MANHATTAN MANHATTAN 982807 199953 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.715501 -74.005205 (40.715501416148484, -74.0052053205853)
102703 26447463 10/07/2013 12:00:00 AM NaN HPD Department of Housing Preservation and Develop... PLUMBING WATER-SUPPLY RESIDENTIAL BUILDING 10007 311 BROADWAY BROADWAY DUANE STREET THOMAS STREET NaN NaN ADDRESS NEW YORK NaN NaN Open NaN 10/07/2013 12:00:00 AM 01 MANHATTAN MANHATTAN 982807 199953 Unspecified MANHATTAN Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified Unspecified NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 40.715501 -74.005205 (40.715501416148484, -74.0052053205853)
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...

69 rows × 52 columns


In [42]:
all_requests.count()


Out[42]:
Unique Key                        111069
Created Date                      111069
Closed Date                        60270
Agency                            111069
Agency Name                       111069
Complaint Type                    111069
Descriptor                        110613
Location Type                      79022
Incident Zip                       98807
Incident Address                   84441
Street Name                        84432
Cross Street 1                     84728
Cross Street 2                     84005
Intersection Street 1              19364
Intersection Street 2              19366
Address Type                      102247
City                               98854
Landmark                              95
Facility Type                      19104
Status                            111069
Due Date                           39239
Resolution Action Updated Date     96507
Community Board                   111069
Borough                           111069
X Coordinate (State Plane)         98143
Y Coordinate (State Plane)         98143
Park Facility Name                111069
Park Borough                      111069
School Name                       111069
School Number                     111048
School Region                     110524
School Code                       110524
School Phone Number               111069
School Address                    111069
School City                       111069
School State                      111069
School Zip                        111069
School Not Found                   38984
School or Citywide Complaint           0
Vehicle Type                          99
Taxi Company Borough                 117
Taxi Pick Up Location               1059
Bridge Highway Name                  185
Bridge Highway Direction             185
Road Ramp                            180
Bridge Highway Segment               219
Garage Lot Name                       49
Ferry Direction                       24
Ferry Terminal Name                   70
Latitude                           98143
Longitude                          98143
Location                           98143
Length: 52, dtype: int64

In [43]:
noise_complaints = all_requests[all_requests['Complaint Type'] == 'Noise - Street/Sidewalk']

In [44]:
noise_complaints['Descriptor'].count()


Out[44]:
1928

Back to our example


In [35]:
# We ran this at the beginning, so we don't have to run it again. Just here as a reminder.
#orig_data = pd.read_csv('./311-service-requests.csv', nrows=100000, parse_dates=['Created Date'])

In [36]:
complaints = orig_data[['Created Date', 'Complaint Type']]
noise_complaints = complaints[complaints['Complaint Type'] == 'Noise - Street/Sidewalk']
noise_complaints.set_index('Created Date').sort_index().resample('H', how=len).plot()


Out[36]:
<matplotlib.axes.AxesSubplot at 0x662ae90>

Indexes


In [37]:
noise_complaints[:3]


Out[37]:
Created Date Complaint Type
0 2013-10-31 02:08:41 Noise - Street/Sidewalk
16 2013-10-31 00:54:03 Noise - Street/Sidewalk
25 2013-10-31 00:35:18 Noise - Street/Sidewalk

In [38]:
noise_complaints = noise_complaints.set_index('Created Date')

In [39]:
noise_complaints[:3]


Out[39]:
Complaint Type
Created Date
2013-10-31 02:08:41 Noise - Street/Sidewalk
2013-10-31 00:54:03 Noise - Street/Sidewalk
2013-10-31 00:35:18 Noise - Street/Sidewalk

Sorting the index

Pandas is awesome for date time index stuff. It was built for dealing with financial data is which is ALL TIME SERIES


In [40]:
noise_complaints = noise_complaints.sort_index()
noise_complaints[:3]


Out[40]:
Complaint Type
Created Date
2013-10-07 15:45:56 Noise - Street/Sidewalk
2013-10-07 16:17:41 Noise - Street/Sidewalk
2013-10-07 16:58:08 Noise - Street/Sidewalk

Counting the complaints each hour


In [41]:
noise_complaints.resample('H', how=len)[:3]


Out[41]:
Complaint Type
Created Date
2013-10-07 15:00:00 1
2013-10-07 16:00:00 2
2013-10-07 17:00:00 0

Example 1: done!


In [42]:
noise_complaints.resample('H', how=len).plot()


Out[42]:
<matplotlib.axes.AxesSubplot at 0x330ea50>

Chaining commands together


In [43]:
complaints = orig_data[['Created Date', 'Complaint Type']]
noise_complaints = complaints[complaints['Complaint Type'] == 'Noise - Street/Sidewalk']
noise_complaints.set_index('Created Date').sort_index().resample('H', how=len).plot()


Out[43]:
<matplotlib.axes.AxesSubplot at 0x3b63910>

Exercise 3: Time series resampling

  • Find the number of noise complaints every day!
  • Find how many complaints about rodents there are each week

In [58]:
noise_complaints = complaints[complaints['Complaint Type'] == 'Noise - Street/Sidewalk']
noise_complaints.set_index('Created Date').sort_index().resample('D', how=len).plot()


Out[58]:
<matplotlib.axes.AxesSubplot at 0x7ff7149ef250>

In [59]:
rat_complaints = complaints[complaints['Complaint Type'] == 'Rodent']
rat_complaints.set_index('Created Date').sort_index().resample('W', how=len).plot()


Out[59]:
<matplotlib.axes.AxesSubplot at 0x7ff7149ef210>

In [ ]:

Example 2: What are the most common complaint types?


In [44]:
orig_data['Complaint Type'].value_counts()


Out[44]:
HEATING                     13983
GENERAL CONSTRUCTION         6859
Street Light Condition       6513
DOF Literature Request       5107
PLUMBING                     4884
PAINT - PLASTER              4671
Blocked Driveway             3992
NONCONST                     3646
Street Condition             3070
Noise                        2942
Traffic Signal Condition     2895
Illegal Parking              2865
Dirty Conditions             2364
ELECTRIC                     2154
Noise - Commercial           2120
...
Window Guard                         2
Legal Services Provider Complaint    2
Public Assembly                      2
Ferry Permit                         1
Trans Fat                            1
DFTA Literature Request              1
Highway Sign - Damaged               1
X-Ray Machine/Equipment              1
DHS Income Savings Requirement       1
Tunnel Condition                     1
Snow                                 1
Stalled Sites                        1
Open Flame Permit                    1
Municipal Parking Facility           1
DWD                                  1
Length: 165, dtype: int64

In [45]:
orig_data['Complaint Type'].value_counts()[:20].plot(kind='bar')


Out[45]:
<matplotlib.axes.AxesSubplot at 0x3702210>

Exercise 4: Do the same thing for a different column


In [65]:
# Your code here.
orig_data['Location Type'].value_counts()[:20].plot(kind='bar')


Out[65]:
<matplotlib.axes.AxesSubplot at 0x7ff714150fd0>

In [68]:
orig_data['Location Type'] == 'Street/Sidewalk'['Incident Zip']


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-68-c10bb0d27352> in <module>()
----> 1 orig_data['Location Type'] == 'Street/Sidewalk'['Incident Zip']

TypeError: string indices must be integers, not str

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:

Example 3: Which weekday has the most noise complaints?


In [50]:
complaints = orig_data[['Created Date', 'Complaint Type']]
noise_complaints = complaints[complaints['Complaint Type'] == 'Noise - Street/Sidewalk']
noise_complaints = noise_complaints.set_index("Created Date")

In [63]:
noise_complaints['weekday'] = noise_complaints.index.weekday
noise_complaints[:3]


Out[63]:
Complaint Type weekday
Created Date
2013-10-31 02:08:41 Noise - Street/Sidewalk 3
2013-10-31 00:54:03 Noise - Street/Sidewalk 3
2013-10-31 00:35:18 Noise - Street/Sidewalk 3

In [64]:
# Count the complaints by weekday
counts_by_weekday = noise_complaints.groupby('weekday').aggregate(len)
counts_by_weekday


Out[64]:
Complaint Type
weekday
0 200
1 187
2 204
3 149
4 180
5 312
6 280

In [65]:
# change the index to be actual days
counts_by_weekday.index = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]

In [66]:
counts_by_weekday.plot(kind='bar')


Out[66]:
<matplotlib.axes.AxesSubplot at 0x6c9da50>

Exercise 5: Count the complaints by hour instead


In [67]:
# Your code here

In [67]:


In [67]:

A few more cool things

String searching


In [77]:
# We need to get rid of the NA values for this to work
street_names = orig_data['Street Name'].fillna('')

In [75]:
manhattan_streets = street_names[street_names.str.contains("MANHATTAN")]
manhattan_streets


Out[75]:
263          MANHATTAN AVENUE
1387         MANHATTAN AVENUE
1589         MANHATTAN AVENUE
1943         MANHATTAN AVENUE
2826         MANHATTAN AVENUE
2968         MANHATTAN AVENUE
3364         MANHATTAN AVENUE
6068         MANHATTAN AVENUE
7359     MANHATTAN BEACH PARK
7360     MANHATTAN BEACH PARK
7917         MANHATTAN AVENUE
10095        MANHATTAN AVENUE
10688        MANHATTAN AVENUE
11043        MANHATTAN AVENUE
12668        MANHATTAN AVENUE
...
77358             MANHATTAN AVENUE
77404    MANHATTAN COLLEGE PARKWAY
77885             MANHATTAN AVENUE
82118         MANHATTAN BEACH PARK
82122         MANHATTAN BEACH PARK
84985                MANHATTAN AVE
85032             MANHATTAN AVENUE
85202              MANHATTAN COURT
85602             MANHATTAN AVENUE
85680             MANHATTAN AVENUE
89159             MANHATTAN AVENUE
91088    MANHATTAN COLLEGE PARKWAY
93843         MANHATTAN BEACH PARK
95950             MANHATTAN AVENUE
96630             MANHATTAN AVENUE
Name: Street Name, Length: 106, dtype: object

In [76]:
manhattan_streets.value_counts()


Out[76]:
MANHATTAN AVENUE             88
MANHATTAN COLLEGE PARKWAY     7
MANHATTAN BEACH PARK          6
MANHATTAN STREET              3
MANHATTAN COURT               1
MANHATTAN AVE                 1
dtype: int64

Looking at complaints close to us


In [91]:
# Our current latitude and longitude
our_lat, our_long = 40.714151,-74.00878

In [94]:
distance_from_us = (orig_data['Longitude'] - our_long)**2 + (orig_data['Latitude'] - our_lat)**2

In [96]:
pd.Series(distance_from_us).hist()


Out[96]:
<matplotlib.axes.AxesSubplot at 0xa5d7350>

In [103]:
close_complaints = orig_data[distance_from_us < 0.00005]

In [106]:
close_complaints['Complaint Type'].value_counts()[:20].plot(kind='bar')


Out[106]:
<matplotlib.axes.AxesSubplot at 0x1988ff90>

In [96]:
tl=pd.read_csv('./md-tl.csv')
ps=pd.read_csv('./md-pslist.csv', error_bad_lines=False)


Skipping line 15: expected 11 fields, saw 14
Skipping line 17: expected 11 fields, saw 14


In [97]:
ps.info


Out[97]:
<bound method DataFrame.info of      Offset(V)           Name   PID  PPID  Thds  Hnds    Sess  Wow64       Start      Exit        TZ
0   0x823c8830         System     4     0    51   269  ------      0         NaN       NaN       NaN
1   0x8211a020       smss.exe   360     4     3    19  ------      0  2012-04-28  01:56:37  UTC+0000
2   0x82129220      csrss.exe   596   360    11   340       0      0  2012-04-28  01:56:38  UTC+0000
3   0x82194020   winlogon.exe   624   360    17   535       0      0  2012-04-28  01:56:39  UTC+0000
4   0x82146460   services.exe   672   624    15   238       0      0  2012-04-28  01:56:39  UTC+0000
5   0x821497f0      lsass.exe   684   624    26   410       0      0  2012-04-28  01:56:39  UTC+0000
6   0x821d4500    svchost.exe   852   672    22   203       0      0  2012-04-28  01:56:40  UTC+0000
7   0x82147da0    svchost.exe   940   672     9   215       0      0  2012-04-28  01:56:41  UTC+0000
8   0x8211a880    svchost.exe  1024   672    75  1480       0      0  2012-04-28  01:56:41  UTC+0000
9   0x8217d020    svchost.exe  1072   672     5    82       0      0  2012-04-28  01:56:41  UTC+0000
10  0x82124020    svchost.exe  1124   672    14   193       0      0  2012-04-28  01:56:42  UTC+0000
11  0x822b0020    spoolsv.exe  1356   672    11   106       0      0  2012-04-28  01:56:43  UTC+0000
12  0x8202a020        alg.exe  1880   672     5   102       0      0  2012-04-28  01:56:53  UTC+0000
13  0x8214a020   explorer.exe  1096  1212    13   317       0      0  2012-04-28  02:20:54  UTC+0000
14  0x82222268  reader_sl.exe  2008  1096     2    27       0      0  2012-04-28  02:20:56  UTC+0000
15  0x821f67e8   AdobeARM.exe  1796  1096    10   215       0      0  2012-04-28  02:20:56  UTC+0000
16  0x82247da0        cmd.exe  1120  1096     1    33       0      0  2012-04-28  02:21:15  UTC+0000
17  0x821ab3d0        mdd.exe  1396  1120     1    24       0      0  2012-04-28  02:23:20  UTC+0000

[18 rows x 11 columns]>

In [ ]:


In [ ]:


In [ ]:


In [93]:
pd.read_csv?

In [ ]:


In [ ]:


In [80]:
tl.columns


Out[80]:
Index([u'Date', u'Size', u'Type', u'Mode', u'UID', u'GID', u'Meta', u'File Name'], dtype='object')

In [89]:
tl[tl['File Name'] <> 'exe']


Out[89]:
Date Size Type Mode UID GID Meta File Name
0 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] AdobeARM.exe/PID: 1796/PPID: 1096/PO...
1 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] AdobeARM.exe/PID: 1796/PPID: 1096/PO...
2 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] AdobeARM.exe/PID: 1796/PPID: 1096/PO...
3 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] alg.exe/PID: 1880/PPID: 672/POffset:...
4 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] cmd.exe/PID: 1120/PPID: 1096/POffset...
5 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] csrss.exe/PID: 596/PPID: 360/POffset...
6 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] explorer.exe/PID: 1096/PPID: 1212/PO...
7 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] lsass.exe/PID: 684/PPID: 624/POffset...
8 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] mdd.exe/PID: 1396/PPID: 1120/POffset...
9 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] reader_sl.exe/PID: 2008/PPID: 1096/P...
10 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] reader_sl.exe/PID: 2008/PPID: 1096/P...
11 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] services.exe/PID: 672/PPID: 624/POff...
12 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] smss.exe/PID: 360/PPID: 4/POffset: 0...
13 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] smss.exe/PID: 360/PPID: 4/POffset: 0...
14 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] spoolsv.exe/PID: 1356/PPID: 672/POff...
15 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] spoolsv.exe/PID: 1356/PPID: 672/POff...
16 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] svchost.exe/PID: 1024/PPID: 672/POff...
17 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] svchost.exe/PID: 1024/PPID: 672/POff...
18 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] svchost.exe/PID: 1072/PPID: 672/POff...
19 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] svchost.exe/PID: 1072/PPID: 672/POff...
20 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] svchost.exe/PID: 1092/PPID: 672/POff...
21 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] svchost.exe/PID: 1092/PPID: 672/POff...
22 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] svchost.exe/PID: 1124/PPID: 672/POff...
23 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] svchost.exe/PID: 1204/PPID: 672/POff...
24 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] svchost.exe/PID: 1204/PPID: 672/POff...
25 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] svchost.exe/PID: 1204/PPID: 672/POff...
26 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] svchost.exe/PID: 852/PPID: 672/POffs...
27 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] svchost.exe/PID: 852/PPID: 672/POffs...
28 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] svchost.exe/PID: 940/PPID: 672/POffs...
29 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] winlogon.exe/PID: 624/PPID: 360/POff...
30 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [PROCESS] winlogon.exe/PID: 624/PPID: 360/POff...
31 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] AdobeARM.exe/PID: 1796/TID: 1080
32 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] AdobeARM.exe/PID: 1796/TID: 1132
33 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] AdobeARM.exe/PID: 1796/TID: 1232
34 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] AdobeARM.exe/PID: 1796/TID: 124
35 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] AdobeARM.exe/PID: 1796/TID: 1560
36 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] AdobeARM.exe/PID: 1796/TID: 1792
37 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] AdobeARM.exe/PID: 1796/TID: 1896
38 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] AdobeARM.exe/PID: 1796/TID: 496
39 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] AdobeARM.exe/PID: 1796/TID: 576
40 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] AdobeARM.exe/PID: 1796/TID: 936
41 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] System/PID: 4/TID: 100
42 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] System/PID: 4/TID: 104
43 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] System/PID: 4/TID: 108
44 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] System/PID: 4/TID: 1108
45 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] System/PID: 4/TID: 116
46 Xxx Xxx 00 0000 00:00:00 0 .acb --------------- 0 0 0 [THREAD] System/PID: 4/TID: 12
47 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] System/PID: 4/TID: 136
48 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] System/PID: 4/TID: 140
49 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] System/PID: 4/TID: 1424
50 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] System/PID: 4/TID: 1428
51 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] System/PID: 4/TID: 1432
52 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] System/PID: 4/TID: 1436
53 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] System/PID: 4/TID: 144
54 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] System/PID: 4/TID: 1448
55 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] System/PID: 4/TID: 148
56 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] System/PID: 4/TID: 156
57 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] System/PID: 4/TID: 16
58 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] System/PID: 4/TID: 160
59 Xxx Xxx 00 0000 00:00:00 0 m... --------------- 0 0 0 [THREAD] System/PID: 4/TID: 1628
... ... ... ... ... ... ... ...

1695 rows × 8 columns


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [83]:
tl.head


Out[83]:
<bound method DataFrame.head of                         Date  Size  Type             Mode  UID  GID  Meta                                          File Name
0   Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] AdobeARM.exe/PID: 1796/PPID: 1096/PO...
1   Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] AdobeARM.exe/PID: 1796/PPID: 1096/PO...
2   Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] AdobeARM.exe/PID: 1796/PPID: 1096/PO...
3   Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] alg.exe/PID: 1880/PPID: 672/POffset:...
4   Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] cmd.exe/PID: 1120/PPID: 1096/POffset...
5   Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] csrss.exe/PID: 596/PPID: 360/POffset...
6   Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] explorer.exe/PID: 1096/PPID: 1212/PO...
7   Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] lsass.exe/PID: 684/PPID: 624/POffset...
8   Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] mdd.exe/PID: 1396/PPID: 1120/POffset...
9   Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] reader_sl.exe/PID: 2008/PPID: 1096/P...
10  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] reader_sl.exe/PID: 2008/PPID: 1096/P...
11  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] services.exe/PID: 672/PPID: 624/POff...
12  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] smss.exe/PID: 360/PPID: 4/POffset: 0...
13  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] smss.exe/PID: 360/PPID: 4/POffset: 0...
14  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] spoolsv.exe/PID: 1356/PPID: 672/POff...
15  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] spoolsv.exe/PID: 1356/PPID: 672/POff...
16  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] svchost.exe/PID: 1024/PPID: 672/POff...
17  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] svchost.exe/PID: 1024/PPID: 672/POff...
18  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] svchost.exe/PID: 1072/PPID: 672/POff...
19  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] svchost.exe/PID: 1072/PPID: 672/POff...
20  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] svchost.exe/PID: 1092/PPID: 672/POff...
21  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] svchost.exe/PID: 1092/PPID: 672/POff...
22  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] svchost.exe/PID: 1124/PPID: 672/POff...
23  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] svchost.exe/PID: 1204/PPID: 672/POff...
24  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] svchost.exe/PID: 1204/PPID: 672/POff...
25  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] svchost.exe/PID: 1204/PPID: 672/POff...
26  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] svchost.exe/PID: 852/PPID: 672/POffs...
27  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] svchost.exe/PID: 852/PPID: 672/POffs...
28  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] svchost.exe/PID: 940/PPID: 672/POffs...
29  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] winlogon.exe/PID: 624/PPID: 360/POff...
30  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0  [PROCESS] winlogon.exe/PID: 624/PPID: 360/POff...
31  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0          [THREAD] AdobeARM.exe/PID: 1796/TID: 1080
32  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0          [THREAD] AdobeARM.exe/PID: 1796/TID: 1132
33  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0          [THREAD] AdobeARM.exe/PID: 1796/TID: 1232
34  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0           [THREAD] AdobeARM.exe/PID: 1796/TID: 124
35  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0          [THREAD] AdobeARM.exe/PID: 1796/TID: 1560
36  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0          [THREAD] AdobeARM.exe/PID: 1796/TID: 1792
37  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0          [THREAD] AdobeARM.exe/PID: 1796/TID: 1896
38  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0           [THREAD] AdobeARM.exe/PID: 1796/TID: 496
39  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0           [THREAD] AdobeARM.exe/PID: 1796/TID: 576
40  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0           [THREAD] AdobeARM.exe/PID: 1796/TID: 936
41  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0                    [THREAD] System/PID: 4/TID: 100
42  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0                    [THREAD] System/PID: 4/TID: 104
43  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0                    [THREAD] System/PID: 4/TID: 108
44  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0                   [THREAD] System/PID: 4/TID: 1108
45  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0                    [THREAD] System/PID: 4/TID: 116
46  Xxx Xxx 00 0000 00:00:00     0  .acb  ---------------    0    0     0                     [THREAD] System/PID: 4/TID: 12
47  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0                    [THREAD] System/PID: 4/TID: 136
48  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0                    [THREAD] System/PID: 4/TID: 140
49  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0                   [THREAD] System/PID: 4/TID: 1424
50  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0                   [THREAD] System/PID: 4/TID: 1428
51  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0                   [THREAD] System/PID: 4/TID: 1432
52  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0                   [THREAD] System/PID: 4/TID: 1436
53  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0                    [THREAD] System/PID: 4/TID: 144
54  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0                   [THREAD] System/PID: 4/TID: 1448
55  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0                    [THREAD] System/PID: 4/TID: 148
56  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0                    [THREAD] System/PID: 4/TID: 156
57  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0                     [THREAD] System/PID: 4/TID: 16
58  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0                    [THREAD] System/PID: 4/TID: 160
59  Xxx Xxx 00 0000 00:00:00     0  m...  ---------------    0    0     0                   [THREAD] System/PID: 4/TID: 1628
                         ...   ...   ...              ...  ...  ...   ...                                                ...

[1695 rows x 8 columns]>

In [ ]:


In [ ]:


In [77]:
tl[1:].head


Out[77]:
<bound method DataFrame.head of    0|[END LIVE RESPONSE]|0|---------------|0|0|0|1391430696|1391430696|1391430696|1391430696
1   0|[PROCESS] conhost.exe/PID: 2272/PPID: 380/PO...                                       
2   0|[PROCESS] taskhost.exe/PID: 140/PPID: 484/PO...                                       
3   0|[PROCESS] conhost.exe/PID: 2752/PPID: 380/PO...                                       
4   0|[PROCESS] conhost.exe/PID: 3916/PPID: 380/PO...                                       
5   0|[PROCESS] msdtc.exe/PID: 840/PPID: 484/POffs...                                       
6   0|[PROCESS] SearchFilterHo/PID: 3128/PPID: 171...                                       
7   0|[PROCESS] SearchIndexer./PID: 1712/PPID: 484...                                       
8   0|[PROCESS] svchost.exe/PID: 1248/PPID: 484/PO...                                       
9   0|[PROCESS] wuauclt.exe/PID: 2280/PPID: 844/PO...                                       
10  0|[PROCESS] svchost.exe/PID: 588/PPID: 484/POf...                                       
11  0|[PROCESS] svchost.exe/PID: 664/PPID: 484/POf...                                       
12  0|[PROCESS] dllhost.exe/PID: 1676/PPID: 588/PO...                                       
13  0|[PROCESS] svchost.exe/PID: 752/PPID: 484/POf...                                       
14  0|[PROCESS] cmd.exe/PID: 3656/PPID: 3220/POffs...                                       
15  0|[PROCESS] svchost.exe/PID: 792/PPID: 484/POf...                                       
16  0|[PROCESS] svchost.exe/PID: 820/PPID: 484/POf...                                       
17  0|[PROCESS] svchost.exe/PID: 844/PPID: 484/POf...                                       
18  0|[PROCESS] SearchProtocol/PID: 3452/PPID: 171...                                       
19  0|[PROCESS] svchost.exe/PID: 588/PPID: 484/POf...                                       
20  0|[PROCESS] svchost.exe/PID: 664/PPID: 484/POf...                                       
21  0|[PROCESS] dllhost.exe/PID: 1676/PPID: 588/PO...                                       
22  0|[PROCESS] svchost.exe/PID: 752/PPID: 484/POf...                                       
23  0|[PROCESS] cmd.exe/PID: 3656/PPID: 3220/POffs...                                       
24  0|[PROCESS] svchost.exe/PID: 792/PPID: 484/POf...                                       
25  0|[PROCESS] svchost.exe/PID: 820/PPID: 484/POf...                                       
26  0|[PROCESS] svchost.exe/PID: 844/PPID: 484/POf...                                       
27  0|[PROCESS] SearchProtocol/PID: 3452/PPID: 171...                                       
28  0|[PROCESS] svchost.exe/PID: 588/PPID: 484/POf...                                       
29  0|[PROCESS] csrss.exe/PID: 380/PPID: 372/POffs...                                       
30  0|[PROCESS] wininit.exe/PID: 388/PPID: 328/POf...                                       
31  0|[PROCESS] services.exe/PID: 484/PPID: 388/PO...                                       
32  0|[PROCESS] lsass.exe/PID: 492/PPID: 388/POffs...                                       
33  0|[PROCESS] lsm.exe/PID: 500/PPID: 388/POffset...                                       
34  0|[PROCESS] svchost.exe/PID: 1316/PPID: 484/PO...                                       
35  0|[PROCESS] csrss.exe/PID: 336/PPID: 328/POffs...                                       
36  0|[PROCESS] dllhost.exe/PID: 2012/PPID: 484/PO...                                       
37  0|[PROCESS] svchost.exe/PID: 1796/PPID: 484/PO...                                       
38  0|[PROCESS] vmtoolsd.exe/PID: 1516/PPID: 484/P...                                       
39  0|[PROCESS] TPAutoConnSvc./PID: 1688/PPID: 484...                                       
40  0|[PROCESS] explorer.exe/PID: 2052/PPID: 1808/...                                       
41  0|[PROCESS] svchost.exe/PID: 2644/PPID: 484/PO...                                       
42  0|[PROCESS] winlogon.exe/PID: 424/PPID: 372/PO...                                       
43  0|[PROCESS] svchost.exe/PID: 1176/PPID: 484/PO...                                       
44  0|[PROCESS] spoolsv.exe/PID: 1288/PPID: 484/PO...                                       
45  0|[PROCESS] DumpIt.exe/PID: 3060/PPID: 2052/PO...                                       
46  0|[PROCESS] VMwareTray.exe/PID: 4092/PPID: 205...                                       
47  0|[PROCESS] TPAutoConnect./PID: 4044/PPID: 168...                                       
48  0|[PROCESS] vmtoolsd.exe/PID: 2116/PPID: 2052/...                                       
49  0|[PROCESS] dllhost.exe/PID: 1920/PPID: 588/PO...                                       
50  0|[PROCESS] smss.exe/PID: 248/PPID: 4/POffset:...                                       
51  0|[PROCESS] dwm.exe/PID: 340/PPID: 792/POffset...                                       
52  0|[PROCESS] notepad.exe/PID: 1896/PPID: 1524/P...                                       
53  0|[PROCESS] audiodg.exe/PID: 3936/PPID: 752/PO...                                       
54  0|[PROCESS] cmd.exe/PID: 1128/PPID: 3220/POffs...                                       
55  0|[PROCESS] runddl32.exe/PID: 1524/PPID: 3220/...                                       
56  0|[PROCESS] conhost.exe/PID: 2088/PPID: 380/PO...                                       
57  0|[PROCESS] dllhost.exe/PID: 3636/PPID: 588/PO...                                       
58  0|[PROCESS] System/PID: 4/PPID: 0/POffset: 0x3...                                       
59  0|[NETWORK CONNECTION] 664/0.0.0.0:135 -> 0.0....                                       
60  0|[NETWORK CONNECTION] 388/0.0.0.0:49152 -> 0....                                       
                                                  ...                                       

[1999 rows x 1 columns]>

In [ ]:


In [ ]:


In [ ]:


In [ ]: