2.Python数据分析(数据选择与分析及折线图柱状图Selecting_data_and_analysis_part1)

Wesley13
• 阅读 719

文章目录

  • 2.1 瞄一眼数据

  • 2.2 选行或者列

  • 2.3 选多行

  • 2.4 想统计找出Top类型的数据?

    * coding:utf-8_*_# 作者 :XiangLin# 创建时间 :09/02/2020 12:01# 文件 :2-2_Selecting_data_and_analysis_part1.py# IDE :PyCharmimport pandas as pdimport matplotlib.pyplot as pltimport warningswarnings.filterwarnings('ignore')# Make the graphs a bit prettier, and bigger# This is necessary to show lots of columns in pandas 0.12.# Not necessary in pandas 0.13.plt.style.use("bmh")plt.rc('font', family='SimHei', size=13) #显示中文pd.set_option('display.max_columns',1000)pd.set_option('display.width', 1000)pd.set_option('display.max_colwidth',1000)

2.1中的数据集有点小啦,咱们这里用一个大一点的数据集

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

其实warning暂时可以不用管,一般是python版本的问题

2.1 瞄一眼数据

dataframe这种格式还是很神奇的,比如说,你要是直接把dataframe丢出去输出一下,它会告诉你最基本的信息。

比如有多少行多少列,有多少非空的值等等。

print(complaints)

输出:        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  \0         26589651  10/31/2013 02:08:41 AM                     NaN   NYPD          New York City Police Department   Noise - Street/Sidewalk                                  Loud Talking                Street/Sidewalk        11432           90-03 169 STREET            169 STREET           90 AVENUE                         91 AVENUE                     NaN                   NaN       ADDRESS              JAMAICA      NaN      Precinct  Assigned  10/31/2013 10:08:41 AM         10/31/2013 02:35:17 AM             12 QUEENS         QUEENS                   1042027.0                    197389.0        Unspecified         QUEENS  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN1         26593698  10/31/2013 02:01:04 AM                     NaN   NYPD          New York City Police Department           Illegal Parking                  Commercial Overnight Parking                Street/Sidewalk        11378                  58 AVENUE             58 AVENUE            58 PLACE                         59 STREET                     NaN                   NaN     BLOCKFACE              MASPETH      NaN      Precinct      Open  10/31/2013 10:01:04 AM                            NaN             05 QUEENS         QUEENS                   1009349.0                    201984.0        Unspecified         QUEENS  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN2         26594139  10/31/2013 02:00:24 AM  10/31/2013 02:40:32 AM   NYPD          New York City Police Department        Noise - Commercial                              Loud Music/Party            Club/Bar/Restaurant        10032              4060 BROADWAY              BROADWAY     WEST 171 STREET                   WEST 172 STREET                     NaN                   NaN       ADDRESS             NEW YORK      NaN      Precinct    Closed  10/31/2013 10:00:24 AM         10/31/2013 02:39:42 AM          12 MANHATTAN      MANHATTAN                   1001088.0                    246531.0        Unspecified      MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN3         26595721  10/31/2013 01:56:23 AM  10/31/2013 02:21:48 AM   NYPD          New York City Police Department           Noise - Vehicle                                Car/Truck Horn                Street/Sidewalk        10023             WEST 72 STREET        WEST 72 STREET     COLUMBUS AVENUE                  AMSTERDAM AVENUE                     NaN                   NaN     BLOCKFACE             NEW YORK      NaN      Precinct    Closed  10/31/2013 09:56:23 AM         10/31/2013 02:21:10 AM          07 MANHATTAN      MANHATTAN                    989730.0                    222727.0        Unspecified      MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN4         26590930  10/31/2013 01:53:44 AM                     NaN  DOHMH  Department of Health and Mental Hygiene                    Rodent                  Condition Attracting Rodents                     Vacant Lot        10027            WEST 124 STREET       WEST 124 STREET        LENOX AVENUE  ADAM CLAYTON POWELL JR BOULEVARD                     NaN                   NaN     BLOCKFACE             NEW YORK      NaN           NaN   Pending  11/30/2013 01:53:44 AM         10/31/2013 01:59:54 AM          10 MANHATTAN      MANHATTAN                    998815.0                    233545.0        Unspecified      MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN5         26592370  10/31/2013 01:46:52 AM                     NaN   NYPD          New York City Police Department        Noise - Commercial                              Banging/Pounding            Club/Bar/Restaurant        11372                  37 AVENUE             37 AVENUE           84 STREET                         85 STREET                     NaN                   NaN     BLOCKFACE      JACKSON HEIGHTS      NaN      Precinct      Open  10/31/2013 09:46:52 AM                            NaN             03 QUEENS         QUEENS                   1016948.0                    212540.0        Unspecified         QUEENS  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN6         26595682  10/31/2013 01:46:40 AM                     NaN   NYPD          New York City Police Department          Blocked Driveway                                     No Access                Street/Sidewalk        11419          107-50 109 STREET            109 STREET          107 AVENUE                        109 AVENUE                     NaN                   NaN       ADDRESS  SOUTH RICHMOND HILL      NaN      Precinct  Assigned  10/31/2013 09:46:40 AM         10/31/2013 01:59:51 AM             10 QUEENS         QUEENS                   1030919.0                    187622.0        Unspecified         QUEENS  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN7         26595195  10/31/2013 01:44:19 AM  10/31/2013 01:58:49 AM   NYPD          New York City Police Department        Noise - Commercial                              Loud Music/Party            Club/Bar/Restaurant        11417  137-09 CROSSBAY BOULEVARD    CROSSBAY BOULEVARD       PITKIN AVENUE                  VAN WICKLEN ROAD                     NaN                   NaN       ADDRESS           OZONE PARK      NaN      Precinct    Closed  10/31/2013 09:44:19 AM         10/31/2013 01:58:49 AM             10 QUEENS         QUEENS                   1027776.0                    184076.0        Unspecified         QUEENS  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN8         26590540  10/31/2013 01:44:14 AM  10/31/2013 02:28:04 AM   NYPD          New York City Police Department        Noise - Commercial                                  Loud Talking            Club/Bar/Restaurant        10011         258 WEST 15 STREET        WEST 15 STREET            7 AVENUE                          8 AVENUE                     NaN                   NaN       ADDRESS             NEW YORK      NaN      Precinct    Closed  10/31/2013 09:44:14 AM         10/31/2013 02:00:56 AM          04 MANHATTAN      MANHATTAN                    984031.0                    208847.0        Unspecified      MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN9         26594392  10/31/2013 01:34:41 AM  10/31/2013 02:23:51 AM   NYPD          New York City Police Department        Noise - Commercial                              Loud Music/Party            Club/Bar/Restaurant        11225        835 NOSTRAND AVENUE       NOSTRAND AVENUE        UNION STREET                  PRESIDENT STREET                     NaN                   NaN       ADDRESS             BROOKLYN      NaN      Precinct    Closed  10/31/2013 09:34:41 AM         10/31/2013 01:48:26 AM           09 BROOKLYN       BROOKLYN                    997941.0                    182725.0        Unspecified       BROOKLYN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN10        26595176  10/31/2013 01:25:12 AM                     NaN   NYPD          New York City Police Department  Noise - House of Worship                              Loud Music/Party               House of Worship        11218             3775 18 AVENUE             18 AVENUE       EAST 9 STREET                     EAST 8 STREET                     NaN                   NaN       ADDRESS             BROOKLYN      NaN      Precinct      Open  10/31/2013 09:25:12 AM                            NaN           14 BROOKLYN       BROOKLYN                    992726.0                    170399.0        Unspecified       BROOKLYN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN11        26591982  10/31/2013 01:24:14 AM  10/31/2013 01:54:39 AM   NYPD          New York City Police Department        Noise - Commercial                              Loud Music/Party            Club/Bar/Restaurant        10003               187 2 AVENUE              2 AVENUE      EAST 11 STREET                    EAST 12 STREET                     NaN                   NaN       ADDRESS             NEW YORK      NaN      Precinct    Closed  10/31/2013 09:24:14 AM         10/31/2013 01:54:39 AM          03 MANHATTAN      MANHATTAN                    988110.0                    205533.0        Unspecified      MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN12        26594169  10/31/2013 01:20:57 AM  10/31/2013 02:12:31 AM   NYPD          New York City Police Department           Illegal Parking                Double Parked Blocking Vehicle                Street/Sidewalk        10029          65 EAST 99 STREET        EAST 99 STREET      MADISON AVENUE                       PARK AVENUE                     NaN                   NaN       ADDRESS             NEW YORK      NaN      Precinct    Closed  10/31/2013 09:20:57 AM         10/31/2013 01:42:05 AM          11 MANHATTAN      MANHATTAN                    997470.0                    226725.0        Unspecified      MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN13        26594391  10/31/2013 01:20:13 AM                     NaN   NYPD          New York City Police Department           Noise - Vehicle                                 Engine Idling                Street/Sidewalk        10466                        NaN                   NaN                 NaN                               NaN           STRANG AVENUE       AMUNDSON AVENUE  INTERSECTION                BRONX      NaN      Precinct      Open  10/31/2013 09:20:13 AM                            NaN              12 BRONX          BRONX                   1029467.0                    264124.0        Unspecified          BRONX  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN14        26590917  10/31/2013 01:19:54 AM                     NaN  DOHMH  Department of Health and Mental Hygiene                    Rodent                                  Rat Sighting  1-2 Family Mixed Use Building        11219                  63 STREET             63 STREET           13 AVENUE                         14 AVENUE                     NaN                   NaN     BLOCKFACE             BROOKLYN      NaN           NaN   Pending  11/30/2013 01:19:54 AM         10/31/2013 01:29:26 AM           10 BROOKLYN       BROOKLYN                    984467.0                    167519.0        Unspecified       BROOKLYN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN15        26591458  10/31/2013 01:14:02 AM  10/31/2013 01:30:34 AM   NYPD          New York City Police Department  Noise - House of Worship                              Loud Music/Party               House of Worship        10025                        NaN                   NaN                 NaN                               NaN        WEST   99 STREET              BROADWAY  INTERSECTION             NEW YORK      NaN      Precinct    Closed  10/31/2013 09:14:02 AM         10/31/2013 01:30:34 AM          07 MANHATTAN      MANHATTAN                    992454.0                    229500.0        Unspecified      MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN16        26594086  10/31/2013 12:54:03 AM  10/31/2013 02:16:39 AM   NYPD          New York City Police Department   Noise - Street/Sidewalk                              Loud Music/Party                Street/Sidewalk        10310        173 CAMPBELL AVENUE       CAMPBELL AVENUE    HENDERSON AVENUE                      WINEGAR LANE                     NaN                   NaN       ADDRESS        STATEN ISLAND      NaN      Precinct    Closed  10/31/2013 08:54:03 AM         10/31/2013 02:07:14 AM      01 STATEN ISLAND  STATEN ISLAND                    952013.0                    171076.0        Unspecified  STATEN ISLAND  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN17        26595117  10/31/2013 12:52:46 AM                     NaN   NYPD          New York City Police Department           Illegal Parking                 Posted Parking Sign Violation                Street/Sidewalk        11236                        NaN                   NaN                 NaN                               NaN        ROCKAWAY PARKWAY       SKIDMORE AVENUE  INTERSECTION             BROOKLYN      NaN      Precinct      Open  10/31/2013 08:52:46 AM                            NaN           18 BROOKLYN       BROOKLYN                   1015289.0                    169710.0        Unspecified       BROOKLYN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN18        26590389  10/31/2013 12:51:00 AM                     NaN    DOT             Department of Transportation    Street Light Condition                              Street Light Out                            NaN          NaN                226 42 ST E               42 ST E          CHURCH AVE                        SNYDER AVE                     NaN                   NaN       ADDRESS                  NaN      NaN           NaN      Open                     NaN                            NaN  Unspecified BROOKLYN       BROOKLYN                         NaN                         NaN        Unspecified       BROOKLYN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified              NaN                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN19        26594210  10/31/2013 12:46:27 AM                     NaN   NYPD          New York City Police Department        Noise - Commercial                              Loud Music/Party            Club/Bar/Restaurant        10033                        NaN                   NaN                 NaN                               NaN        WEST  184 STREET              BROADWAY  INTERSECTION             NEW YORK      NaN      Precinct  Assigned  10/31/2013 08:46:27 AM         10/31/2013 01:32:41 AM          12 MANHATTAN      MANHATTAN                   1002294.0                    249712.0        Unspecified      MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN20        26592932  10/31/2013 12:43:47 AM  10/31/2013 12:56:20 AM   NYPD          New York City Police Department  Noise - House of Worship                              Loud Music/Party               House of Worship        11216             778 PARK PLACE            PARK PLACE       ROGERS AVENUE                   NOSTRAND AVENUE                     NaN                   NaN       ADDRESS             BROOKLYN      NaN      Precinct    Closed  10/31/2013 08:43:47 AM         10/31/2013 12:56:20 AM           08 BROOKLYN       BROOKLYN                    997608.0                    184656.0        Unspecified       BROOKLYN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN21        26594152  10/31/2013 12:41:17 AM  10/31/2013 01:04:37 AM   NYPD          New York City Police Department        Noise - Commercial                              Banging/Pounding               Store/Commercial        10016              155 E 34TH ST             E 34TH ST                 NaN                               NaN                     NaN                   NaN       LATLONG             NEW YORK      NaN      Precinct    Closed  10/31/2013 08:41:17 AM         10/31/2013 01:04:38 AM          06 MANHATTAN      MANHATTAN                    990133.0                    211136.0        Unspecified      MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN22        26589678  10/31/2013 12:39:55 AM                     NaN   NYPD          New York City Police Department           Noise - Vehicle                               Car/Truck Music                Street/Sidewalk        11419                        NaN                   NaN                 NaN                               NaN              112 STREET       ATLANTIC AVENUE  INTERSECTION  SOUTH RICHMOND HILL      NaN      Precinct      Open  10/31/2013 08:39:55 AM                            NaN             09 QUEENS         QUEENS                   1030314.0                    191578.0        Unspecified         QUEENS  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN23        26592304  10/31/2013 12:38:00 AM                     NaN   NYPD          New York City Police Department        Noise - Commercial                              Loud Music/Party            Club/Bar/Restaurant        11216        371 TOMPKINS AVENUE       TOMPKINS AVENUE      MADISON STREET                     PUTNAM AVENUE                     NaN                   NaN       ADDRESS             BROOKLYN      NaN      Precinct  Assigned  10/31/2013 08:38:00 AM         10/31/2013 01:16:53 AM           03 BROOKLYN       BROOKLYN                    999720.0                    188825.0        Unspecified       BROOKLYN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN24        26591892  10/31/2013 12:37:16 AM                     NaN   NYPD          New York City Police Department          Blocked Driveway                                Partial Access                Street/Sidewalk        10305            1496 BAY STREET            BAY STREET        LYMAN AVENUE                       SCHOOL ROAD                     NaN                   NaN       ADDRESS        STATEN ISLAND      NaN      Precinct  Assigned  10/31/2013 08:37:16 AM         10/31/2013 12:52:10 AM      01 STATEN ISLAND  STATEN ISLAND                    967283.0                    160518.0        Unspecified  STATEN ISLAND  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN25        26591573  10/31/2013 12:35:18 AM  10/31/2013 02:41:35 AM   NYPD          New York City Police Department   Noise - Street/Sidewalk                                  Loud Talking                Street/Sidewalk        10312          24 PRINCETON LANE        PRINCETON LANE       HAMPTON GREEN                          DEAD END                     NaN                   NaN       ADDRESS        STATEN ISLAND      NaN      Precinct    Closed  10/31/2013 08:35:18 AM         10/31/2013 01:45:17 AM      03 STATEN ISLAND  STATEN ISLAND                    929577.0                    140964.0        Unspecified  STATEN ISLAND  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN26        26590509  10/31/2013 12:33:00 AM                     NaN    DOT             Department of Transportation    Street Light Condition                              Street Light Out                            NaN          NaN                    38 ST E               38 ST E          CHURCH AVE                       LINDEN BLVD                     NaN                   NaN     BLOCKFACE                  NaN      NaN           NaN      Open                     NaN                            NaN  Unspecified BROOKLYN       BROOKLYN                         NaN                         NaN        Unspecified       BROOKLYN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified              NaN                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN27        26591379  10/31/2013 12:32:44 AM                     NaN  DOHMH  Department of Health and Mental Hygiene      Harboring Bees/Wasps                   Bees/Wasps - Not a beekeper   3+ Family Mixed Use Building        10025        501 WEST 110 STREET       WEST 110 STREET    AMSTERDAM AVENUE                          BROADWAY                     NaN                   NaN       ADDRESS             NEW YORK      NaN           NaN      Open  11/30/2013 12:32:44 AM                            NaN          09 MANHATTAN      MANHATTAN                    994143.0                    231888.0        Unspecified      MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN28        26594085  10/31/2013 12:32:08 AM                     NaN   NYPD          New York City Police Department   Noise - Street/Sidewalk                                  Loud Talking                Street/Sidewalk        10026        121 WEST 116 STREET       WEST 116 STREET        LENOX AVENUE                          7 AVENUE                     NaN                   NaN       ADDRESS             NEW YORK      NaN      Precinct  Assigned  10/31/2013 08:32:08 AM         10/31/2013 02:00:57 AM          10 MANHATTAN      MANHATTAN                    997947.0                    231613.0        Unspecified      MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN29        26589201  10/31/2013 12:32:00 AM                     NaN    DOT             Department of Transportation    Street Light Condition                              Street Light Out                            NaN        10309         295 BAYVIEW AVENUE        BAYVIEW AVENUE         VAIL AVENUE                      BAYVIEW LANE                     NaN                   NaN       ADDRESS        STATEN ISLAND      NaN           NaN      Open                     NaN                            NaN      03 STATEN ISLAND  STATEN ISLAND                    927687.0                    127837.0        Unspecified  STATEN ISLAND  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified              NaN                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN...            ...                     ...                     ...    ...                                      ...                       ...                                           ...                            ...          ...                        ...                   ...                 ...                               ...                     ...                   ...           ...                  ...      ...           ...       ...                     ...                            ...                   ...            ...                         ...                         ...                ...            ...          ...           ...           ...          ...                 ...                                                ...          ...          ...          ...              ...                           ...          ...                  ...                   ...                 ...                      ...       ...                    ...             ...111039    26428764  10/04/2013 12:17:03 AM  10/04/2013 12:38:37 AM   NYPD          New York City Police Department        Noise - Commercial                              Loud Music/Party            Club/Bar/Restaurant        10022         249 EAST 53 STREET        EAST 53 STREET            3 AVENUE                          2 AVENUE                     NaN                   NaN       ADDRESS             NEW YORK      NaN      Precinct    Closed  10/04/2013 08:17:03 AM         10/04/2013 12:38:37 AM          06 MANHATTAN      MANHATTAN                    993036.0                    215164.0        Unspecified      MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111040    26426166  10/04/2013 12:16:22 AM  10/04/2013 05:50:49 AM   NYPD          New York City Police Department        Noise - Commercial                              Loud Music/Party               Store/Commercial        10029        252 EAST 110 STREET       EAST 110 STREET            3 AVENUE                          2 AVENUE                     NaN                   NaN       ADDRESS             NEW YORK      NaN      Precinct    Closed  10/04/2013 08:16:22 AM         10/04/2013 05:50:49 AM          11 MANHATTAN      MANHATTAN                   1000407.0                    228425.0        Unspecified      MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111041    26438565  10/04/2013 12:16:00 AM                     NaN    DEP   Department of Environmental Protection                     Noise  Noise: Construction Before/After Hours (NM1)                            NaN        11231       480 VAN BRUNT STREET      VAN BRUNT STREET         REED STREET                          DEAD END                     NaN                   NaN       ADDRESS             BROOKLYN      NaN           NaN      Open                     NaN                            NaN           06 BROOKLYN       BROOKLYN                    979657.0                    184924.0        Unspecified       BROOKLYN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified              NaN                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111042    26428990  10/04/2013 12:15:52 AM  10/04/2013 12:44:52 AM   NYPD          New York City Police Department   Noise - Street/Sidewalk                                  Loud Talking                Street/Sidewalk        10014      733 WASHINGTON STREET     WASHINGTON STREET         BANK STREET                    BETHUNE STREET                     NaN                   NaN       ADDRESS             NEW YORK      NaN      Precinct    Closed  10/04/2013 08:15:52 AM         10/04/2013 12:44:52 AM          02 MANHATTAN      MANHATTAN                    981950.0                    207532.0        Unspecified      MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111043    26432659  10/04/2013 12:15:46 AM  10/04/2013 04:18:45 AM   NYPD          New York City Police Department        Noise - Commercial                              Loud Music/Party            Club/Bar/Restaurant        11218        1213 CORTELYOU ROAD        CORTELYOU ROAD      EAST 12 STREET                    EAST 13 STREET                     NaN                   NaN       ADDRESS             BROOKLYN      NaN      Precinct    Closed  10/04/2013 08:15:46 AM         10/04/2013 04:18:45 AM           14 BROOKLYN       BROOKLYN                    993451.0                    172498.0        Unspecified       BROOKLYN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111044    26426096  10/04/2013 12:14:09 AM  10/04/2013 01:03:46 AM   NYPD          New York City Police Department   Noise - Street/Sidewalk                                  Loud Talking                Street/Sidewalk        10032        539 WEST 162 STREET       WEST 162 STREET  ST NICHOLAS AVENUE                          BROADWAY                     NaN                   NaN       ADDRESS             NEW YORK      NaN      Precinct    Closed  10/04/2013 08:14:09 AM         10/04/2013 01:03:46 AM          12 MANHATTAN      MANHATTAN                   1000571.0                    244054.0        Unspecified      MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111045    26437764  10/04/2013 12:14:00 AM  10/04/2013 12:14:00 AM    DEP   Department of Environmental Protection              Water System                              Dirty Water (WE)                            NaN        10022         251 EAST 51 STREET        EAST 51 STREET            3 AVENUE                          2 AVENUE                     NaN                   NaN       ADDRESS             NEW YORK      NaN           NaN    Closed                     NaN         10/04/2013 12:14:00 AM          06 MANHATTAN      MANHATTAN                    992791.0                    214702.0        Unspecified      MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified              NaN                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111046    26436286  10/04/2013 12:14:00 AM                     NaN    DEP   Department of Environmental Protection                     Noise  Noise: Construction Before/After Hours (NM1)                            NaN        11231       480 VAN BRUNT STREET      VAN BRUNT STREET         REED STREET                          DEAD END                     NaN                   NaN       ADDRESS             BROOKLYN      NaN           NaN      Open                     NaN                            NaN           06 BROOKLYN       BROOKLYN                    979657.0                    184924.0        Unspecified       BROOKLYN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified              NaN                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111047    26428989  10/04/2013 12:13:08 AM  10/04/2013 02:12:47 AM   NYPD          New York City Police Department           Illegal Parking                 Posted Parking Sign Violation                Street/Sidewalk        11434                        NaN                   NaN                 NaN                               NaN  GUY R BREWER BOULEVARD    ROCKAWAY BOULEVARD  INTERSECTION              JAMAICA      NaN      Precinct    Closed  10/04/2013 08:13:08 AM         10/04/2013 02:12:47 AM             13 QUEENS         QUEENS                   1048801.0                    178419.0        Unspecified         QUEENS  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111048    26430030  10/04/2013 12:12:07 AM  10/04/2013 02:45:24 AM   NYPD          New York City Police Department   Noise - Street/Sidewalk                                  Loud Talking                Street/Sidewalk        10027      215 WEST 131ST STREET     WEST 131ST STREET                 NaN                               NaN                     NaN                   NaN       LATLONG             NEW YORK      NaN      Precinct    Closed  10/04/2013 08:12:07 AM         10/04/2013 02:45:24 AM          01 MANHATTAN      MANHATTAN                    999107.0                    235603.0        Unspecified      MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111049    26429663  10/04/2013 12:12:07 AM  10/04/2013 01:03:44 AM   NYPD          New York City Police Department        Noise - Commercial                              Loud Music/Party            Club/Bar/Restaurant        11209              8915 5 AVENUE              5 AVENUE           89 STREET                         90 STREET                     NaN                   NaN       ADDRESS             BROOKLYN      NaN      Precinct    Closed  10/04/2013 08:12:07 AM         10/04/2013 01:03:44 AM           10 BROOKLYN       BROOKLYN                    976525.0                    165015.0        Unspecified       BROOKLYN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111050    26437763  10/04/2013 12:11:00 AM                     NaN    DEP   Department of Environmental Protection                     Noise  Noise: Construction Before/After Hours (NM1)                            NaN        10028                        NaN                   NaN                 NaN                               NaN          EAST 84 STREET           YORK AVENUE  INTERSECTION             NEW YORK      NaN           NaN      Open                     NaN                            NaN          08 MANHATTAN      MANHATTAN                    998629.0                    221493.0        Unspecified      MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified              NaN                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111051    26432955  10/04/2013 12:08:15 AM  10/04/2013 12:48:02 AM   NYPD          New York City Police Department        Noise - Commercial                              Loud Music/Party            Club/Bar/Restaurant        10009         506 EAST 13 STREET        EAST 13 STREET            AVENUE A                          AVENUE B                     NaN                   NaN       ADDRESS             NEW YORK      NaN      Precinct    Closed  10/04/2013 08:08:15 AM         10/04/2013 12:48:03 AM          03 MANHATTAN      MANHATTAN                    989678.0                    205065.0        Unspecified      MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111052    26437035  10/04/2013 12:08:00 AM  10/04/2013 12:13:00 AM    DEP   Department of Environmental Protection              Water System                              Dirty Water (WE)                            NaN        10022         325 EAST 54 STREET        EAST 54 STREET            2 AVENUE                          1 AVENUE                     NaN                   NaN       ADDRESS             NEW YORK      NaN           NaN    Closed                     NaN         10/04/2013 12:13:00 AM          06 MANHATTAN      MANHATTAN                    993688.0                    215099.0        Unspecified      MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified              NaN                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111053    26433197  10/04/2013 12:08:00 AM  10/04/2013 12:00:00 PM   DSNY                        BCC - Queens East         Derelict Vehicles                          14 Derelict Vehicles                         Street        11413          220-11 145 AVENUE            145 AVENUE          221 STREET                        221 STREET                     NaN                   NaN       ADDRESS  Springfield Gardens      NaN   DSNY Garage   Pending                     NaN         10/04/2013 12:08:00 AM             13 QUEENS         QUEENS                   1051511.0                    181411.0        Unspecified         QUEENS  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified              NaN                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111054    26426060  10/04/2013 12:06:39 AM  10/04/2013 12:31:16 AM   NYPD          New York City Police Department   Noise - Street/Sidewalk                                  Loud Talking                Street/Sidewalk        11224       4823 BEACH 48 STREET       BEACH 48 STREET       BODY OF WATER                       SURF AVENUE                     NaN                   NaN       ADDRESS             BROOKLYN      NaN      Precinct    Closed  10/04/2013 08:06:39 AM         10/04/2013 12:31:16 AM           13 BROOKLYN       BROOKLYN                    980859.0                    149681.0        Unspecified       BROOKLYN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111055    26430628  10/04/2013 12:06:28 AM  10/04/2013 12:21:39 AM   NYPD          New York City Police Department        Noise - Commercial                                  Loud Talking            Club/Bar/Restaurant        11209              7915 3 AVENUE              3 AVENUE           79 STREET                         80 STREET                     NaN                   NaN       ADDRESS             BROOKLYN      NaN      Precinct    Closed  10/04/2013 08:06:28 AM         10/04/2013 12:21:39 AM           10 BROOKLYN       BROOKLYN                    976189.0                    168214.0        Unspecified       BROOKLYN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111056    26431648  10/04/2013 12:06:26 AM  10/23/2013 08:14:52 AM    DOT             Department of Transportation     Street Sign - Missing                                      Bus Stop                         Street        11378                        NaN                   NaN                 NaN                               NaN               54 AVENUE             43 STREET  INTERSECTION              MASPETH      NaN           NaN    Closed  10/14/2013 09:38:47 AM         10/23/2013 08:14:52 AM             02 QUEENS         QUEENS                   1005171.0                    206064.0        Unspecified         QUEENS  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111057    26437034  10/04/2013 12:06:00 AM                     NaN    DEP   Department of Environmental Protection                     Noise                   Noise: Jack Hammering (NC2)                            NaN        10036                        NaN                   NaN                 NaN                               NaN          WEST 48 STREET              BROADWAY  INTERSECTION             NEW YORK      NaN           NaN      Open                     NaN                            NaN          05 MANHATTAN      MANHATTAN                    988451.0                    216208.0        Unspecified      MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified              NaN                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111058    26426094  10/04/2013 12:05:12 AM  10/04/2013 01:08:29 AM   NYPD          New York City Police Department        Noise - Commercial                              Loud Music/Party            Club/Bar/Restaurant        11237   211 KNICKERBOCKER AVENUE  KNICKERBOCKER AVENUE    JEFFERSON STREET                   TROUTMAN STREET                     NaN                   NaN       ADDRESS             BROOKLYN      NaN      Precinct    Closed  10/04/2013 08:05:12 AM         10/04/2013 01:08:29 AM           04 BROOKLYN       BROOKLYN                   1004672.0                    195540.0        Unspecified       BROOKLYN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111059    26429040  10/04/2013 12:04:52 AM  10/04/2013 03:01:04 AM   NYPD          New York City Police Department   Noise - Street/Sidewalk                                  Loud Talking                Street/Sidewalk        10003                99 2 AVENUE              2 AVENUE       EAST 5 STREET                     EAST 6 STREET                     NaN                   NaN       ADDRESS             NEW YORK      NaN      Precinct    Closed  10/04/2013 08:04:52 AM         10/04/2013 03:01:04 AM          03 MANHATTAN      MANHATTAN                    987393.0                    204234.0        Unspecified      MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111060    26434084  10/04/2013 12:04:00 AM                     NaN    DEP   Department of Environmental Protection                     Noise  Noise: Construction Before/After Hours (NM1)                            NaN        10036                        NaN                   NaN                 NaN                               NaN                8 AVENUE        WEST 47 STREET  INTERSECTION             NEW YORK      NaN           NaN      Open                     NaN                            NaN          04 MANHATTAN      MANHATTAN                    987720.0                    216313.0        Unspecified      MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified              NaN                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111061    26426164  10/04/2013 12:03:00 AM  10/04/2013 02:14:57 AM   NYPD          New York City Police Department        Noise - Commercial                              Loud Music/Party            Club/Bar/Restaurant        11106             30-09 BROADWAY              BROADWAY           30 STREET                         31 STREET                     NaN                   NaN       ADDRESS              ASTORIA      NaN      Precinct    Closed  10/04/2013 08:03:00 AM         10/04/2013 02:14:57 AM             01 QUEENS         QUEENS                   1004746.0                    217004.0        Unspecified         QUEENS  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111062    26439710  10/04/2013 12:03:00 AM  10/04/2013 12:03:00 AM    DEP   Department of Environmental Protection              Water System                              Dirty Water (WE)                            NaN        10022         325 EAST 54 STREET        EAST 54 STREET            2 AVENUE                          1 AVENUE                     NaN                   NaN       ADDRESS             NEW YORK      NaN           NaN    Closed                     NaN         10/04/2013 12:03:00 AM          06 MANHATTAN      MANHATTAN                    993688.0                    215099.0        Unspecified      MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified              NaN                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111063    26435569  10/04/2013 12:02:00 AM  10/04/2013 01:10:00 AM    DEP   Department of Environmental Protection              Water System                              Dirty Water (WE)                            NaN        10022         311 EAST 50 STREET        EAST 50 STREET            2 AVENUE                          1 AVENUE                     NaN                   NaN       ADDRESS             NEW YORK      NaN           NaN    Closed                     NaN         10/04/2013 01:10:00 AM          06 MANHATTAN      MANHATTAN                    993118.0                    214222.0        Unspecified      MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified              NaN                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111064    26426013  10/04/2013 12:01:13 AM  10/07/2013 04:07:16 PM    DPR       Department of Parks and Recreation   Maintenance or Facility                          Structure - Outdoors                           Park        11213                        NaN                   NaN                 NaN                               NaN                     NaN                   NaN           NaN             BROOKLYN      NaN           NaN    Closed  10/18/2013 12:01:13 AM         10/07/2013 04:07:16 PM           08 BROOKLYN       BROOKLYN                         NaN                         NaN        Brower Park       BROOKLYN  Brower Park          B012           NaN          NaN          7189658900  Brooklyn, St. Marks, Kingston Avenues, Park Place     BROOKLYN           NY        11213                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111065    26428083  10/04/2013 12:01:05 AM  10/04/2013 02:13:50 AM   NYPD          New York City Police Department           Illegal Parking                 Posted Parking Sign Violation                Street/Sidewalk        11434                        NaN                   NaN                 NaN                               NaN  GUY R BREWER BOULEVARD    ROCKAWAY BOULEVARD  INTERSECTION              JAMAICA      NaN      Precinct    Closed  10/04/2013 08:01:05 AM         10/04/2013 02:13:50 AM             13 QUEENS         QUEENS                   1048801.0                    178419.0        Unspecified         QUEENS  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111066    26428987  10/04/2013 12:00:45 AM  10/04/2013 01:25:01 AM   NYPD          New York City Police Department   Noise - Street/Sidewalk                                  Loud Talking                Street/Sidewalk        10016         344 EAST 28 STREET        EAST 28 STREET  MOUNT CARMEL PLACE                          1 AVENUE                     NaN                   NaN       ADDRESS             NEW YORK      NaN      Precinct    Closed  10/04/2013 08:00:45 AM         10/04/2013 01:25:01 AM          06 MANHATTAN      MANHATTAN                    990637.0                    208987.0        Unspecified      MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111067    26426115  10/04/2013 12:00:28 AM  10/04/2013 04:17:32 AM   NYPD          New York City Police Department        Noise - Commercial                                  Loud Talking            Club/Bar/Restaurant        11226       1233 FLATBUSH AVENUE       FLATBUSH AVENUE            AVENUE D                    NEWKIRK AVENUE                     NaN                   NaN       ADDRESS             BROOKLYN      NaN      Precinct    Closed  10/04/2013 08:00:28 AM         10/04/2013 04:17:32 AM           14 BROOKLYN       BROOKLYN                    996654.0                    172515.0        Unspecified       BROOKLYN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified                                        Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN111068    26428033  10/04/2013 12:00:10 AM  10/04/2013 01:20:52 AM   NYPD          New York City Police Department          Blocked Driveway

2.2 选行或者列

上一节提到了,直接用名字就可以取。

print(complaints.columns)print(complaints['Complaint Type'])

输出:Index(['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'], dtype='object')0          Noise - Street/Sidewalk1                  Illegal Parking2               Noise - Commercial3                  Noise - Vehicle4                           Rodent5               Noise - Commercial6                 Blocked Driveway7               Noise - Commercial8               Noise - Commercial9               Noise - Commercial10        Noise - House of Worship11              Noise - Commercial12                 Illegal Parking13                 Noise - Vehicle14                          Rodent15        Noise - House of Worship16         Noise - Street/Sidewalk17                 Illegal Parking18          Street Light Condition19              Noise - Commercial20        Noise - House of Worship21              Noise - Commercial22                 Noise - Vehicle23              Noise - Commercial24                Blocked Driveway25         Noise - Street/Sidewalk26          Street Light Condition27            Harboring Bees/Wasps28         Noise - Street/Sidewalk29          Street Light Condition                    ...111039          Noise - Commercial111040          Noise - Commercial111041                       Noise111042     Noise - Street/Sidewalk111043          Noise - Commercial111044     Noise - Street/Sidewalk111045                Water System111046                       Noise111047             Illegal Parking111048     Noise - Street/Sidewalk111049          Noise - Commercial111050                       Noise111051          Noise - Commercial111052                Water System111053           Derelict Vehicles111054     Noise - Street/Sidewalk111055          Noise - Commercial111056       Street Sign - Missing111057                       Noise111058          Noise - Commercial111059     Noise - Street/Sidewalk111060                       Noise111061          Noise - Commercial111062                Water System111063                Water System111064     Maintenance or Facility111065             Illegal Parking111066     Noise - Street/Sidewalk111067          Noise - Commercial111068            Blocked Driveway

相信大家对python中list的切片操作非常熟悉,这里也一样,比如你要取前5条数据,直接用df[:5]即可。

拿前几条数据出来的原因是,我们可以先熟悉熟悉数据,为后期做分析热热身。

print(complaints[:5])# 合并一下,取出某一列的前5行:print(complaints['Complaint Type'][:5])# 另外你先取列再切片 和 先切片再取列,其实是一样一样的。print(complaints[:5]['Complaint Type'])

输出:   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                                  Location0    26589651  10/31/2013 02:08:41 AM                     NaN   NYPD          New York City Police Department  Noise - Street/Sidewalk                  Loud Talking      Street/Sidewalk        11432  90-03 169 STREET       169 STREET        90 AVENUE                         91 AVENUE                   NaN                   NaN      ADDRESS   JAMAICA      NaN      Precinct  Assigned  10/31/2013 10:08:41 AM         10/31/2013 02:35:17 AM       12 QUEENS     QUEENS                   1042027.0                    197389.0        Unspecified       QUEENS  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified    Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN             NaN                 NaN  40.708275 -73.791604   (40.70827532593202, -73.79160395779721)1    26593698  10/31/2013 02:01:04 AM                     NaN   NYPD          New York City Police Department          Illegal Parking  Commercial Overnight Parking      Street/Sidewalk        11378         58 AVENUE        58 AVENUE         58 PLACE                         59 STREET                   NaN                   NaN    BLOCKFACE   MASPETH      NaN      Precinct      Open  10/31/2013 10:01:04 AM                            NaN       05 QUEENS     QUEENS                   1009349.0                    201984.0        Unspecified       QUEENS  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified    Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN             NaN                 NaN  40.721041 -73.909453  (40.721040535628305, -73.90945306791765)2    26594139  10/31/2013 02:00:24 AM  10/31/2013 02:40:32 AM   NYPD          New York City Police Department       Noise - Commercial              Loud Music/Party  Club/Bar/Restaurant        10032     4060 BROADWAY         BROADWAY  WEST 171 STREET                   WEST 172 STREET                   NaN                   NaN      ADDRESS  NEW YORK      NaN      Precinct    Closed  10/31/2013 10:00:24 AM         10/31/2013 02:39:42 AM    12 MANHATTAN  MANHATTAN                   1001088.0                    246531.0        Unspecified    MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified    Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN             NaN                 NaN  40.843330 -73.939144   (40.84332975466513, -73.93914371913482)3    26595721  10/31/2013 01:56:23 AM  10/31/2013 02:21:48 AM   NYPD          New York City Police Department          Noise - Vehicle                Car/Truck Horn      Street/Sidewalk        10023    WEST 72 STREET   WEST 72 STREET  COLUMBUS AVENUE                  AMSTERDAM AVENUE                   NaN                   NaN    BLOCKFACE  NEW YORK      NaN      Precinct    Closed  10/31/2013 09:56:23 AM         10/31/2013 02:21:10 AM    07 MANHATTAN  MANHATTAN                    989730.0                    222727.0        Unspecified    MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified    Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN             NaN                 NaN  40.778009 -73.980213    (40.7780087446372, -73.98021349023975)4    26590930  10/31/2013 01:53:44 AM                     NaN  DOHMH  Department of Health and Mental Hygiene                   Rodent  Condition Attracting Rodents           Vacant Lot        10027   WEST 124 STREET  WEST 124 STREET     LENOX AVENUE  ADAM CLAYTON POWELL JR BOULEVARD                   NaN                   NaN    BLOCKFACE  NEW YORK      NaN           NaN   Pending  11/30/2013 01:53:44 AM         10/31/2013 01:59:54 AM    10 MANHATTAN  MANHATTAN                    998815.0                    233545.0        Unspecified    MANHATTAN  Unspecified   Unspecified   Unspecified  Unspecified         Unspecified    Unspecified  Unspecified  Unspecified  Unspecified                N                           NaN          NaN                  NaN                   NaN                 NaN                      NaN       NaN                    NaN             NaN             NaN                 NaN  40.807691 -73.947387   (40.80769092704951, -73.94738703491433)0    Noise - Street/Sidewalk1            Illegal Parking2         Noise - Commercial3            Noise - Vehicle4                     Rodent

2.3 选多行

选一行是把这一行的名字告诉它,那选多行呢?恩,传一个名称list给他咯

print(complaints[['Complaint Type','Borough']])# 好吧,再拼一下:多列的前n行。print(complaints[['Complaint Type','Borough']][:10])

输出:                  Complaint Type        Borough0        Noise - Street/Sidewalk         QUEENS1                Illegal Parking         QUEENS2             Noise - Commercial      MANHATTAN3                Noise - Vehicle      MANHATTAN4                         Rodent      MANHATTAN5             Noise - Commercial         QUEENS6               Blocked Driveway         QUEENS7             Noise - Commercial         QUEENS8             Noise - Commercial      MANHATTAN9             Noise - Commercial       BROOKLYN10      Noise - House of Worship       BROOKLYN11            Noise - Commercial      MANHATTAN12               Illegal Parking      MANHATTAN13               Noise - Vehicle          BRONX14                        Rodent       BROOKLYN15      Noise - House of Worship      MANHATTAN16       Noise - Street/Sidewalk  STATEN ISLAND17               Illegal Parking       BROOKLYN18        Street Light Condition       BROOKLYN19            Noise - Commercial      MANHATTAN20      Noise - House of Worship       BROOKLYN21            Noise - Commercial      MANHATTAN22               Noise - Vehicle         QUEENS23            Noise - Commercial       BROOKLYN24              Blocked Driveway  STATEN ISLAND25       Noise - Street/Sidewalk  STATEN ISLAND26        Street Light Condition       BROOKLYN27          Harboring Bees/Wasps      MANHATTAN28       Noise - Street/Sidewalk      MANHATTAN29        Street Light Condition  STATEN ISLAND...                          ...            ...111039        Noise - Commercial      MANHATTAN111040        Noise - Commercial      MANHATTAN111041                     Noise       BROOKLYN111042   Noise - Street/Sidewalk      MANHATTAN111043        Noise - Commercial       BROOKLYN111044   Noise - Street/Sidewalk      MANHATTAN111045              Water System      MANHATTAN111046                     Noise       BROOKLYN111047           Illegal Parking         QUEENS111048   Noise - Street/Sidewalk      MANHATTAN111049        Noise - Commercial       BROOKLYN111050                     Noise      MANHATTAN111051        Noise - Commercial      MANHATTAN111052              Water System      MANHATTAN111053         Derelict Vehicles         QUEENS111054   Noise - Street/Sidewalk       BROOKLYN111055        Noise - Commercial       BROOKLYN111056     Street Sign - Missing         QUEENS111057                     Noise      MANHATTAN111058        Noise - Commercial       BROOKLYN111059   Noise - Street/Sidewalk      MANHATTAN111060                     Noise      MANHATTAN111061        Noise - Commercial         QUEENS111062              Water System      MANHATTAN111063              Water System      MANHATTAN111064   Maintenance or Facility       BROOKLYN111065           Illegal Parking         QUEENS111066   Noise - Street/Sidewalk      MANHATTAN111067        Noise - Commercial       BROOKLYN111068          Blocked Driveway       BROOKLYN[111069 rows x 2 columns]            Complaint Type    Borough0  Noise - Street/Sidewalk     QUEENS1          Illegal Parking     QUEENS2       Noise - Commercial  MANHATTAN3          Noise - Vehicle  MANHATTAN4                   Rodent  MANHATTAN5       Noise - Commercial     QUEENS6         Blocked Driveway     QUEENS7       Noise - Commercial     QUEENS8       Noise - Commercial  MANHATTAN9       Noise - Commercial   BROOKLYN

2.4 想统计找出Top类型的数据?

dataframe真的很智能,比如你告诉它,我要统计一下数量了!(用.value_counts()函数),那它就帮你统计数量了:

print(complaints['Complaint Type'].value_counts())# 注意哈,咱们拿到的结果是排过序的,也就是说如果我只要top 10的话,其实截断一下就可以了:complaints_counts = complaints['Complaint Type'].value_counts()print(complaints_counts[:10])

HEATING                                 14200GENERAL CONSTRUCTION                     7471Street Light Condition                   7117DOF Literature Request                   5797PLUMBING                                 5373PAINT - PLASTER                          5149Blocked Driveway                         4590NONCONST                                 3998Street Condition                         3473Illegal Parking                          3343Noise                                    3321Traffic Signal Condition                 3145Dirty Conditions                         2653Water System                             2636Noise - Commercial                       2578ELECTRIC                                 2350Broken Muni Meter                        2070Noise - Street/Sidewalk                  1928Sanitation Condition                     1824Rodent                                   1632Sewer                                    1627Taxi Complaint                           1227Consumer Complaint                       1227Damaged Tree                             1180Overgrown Tree/Branches                  1083Missed Collection (All Materials)         973Graffiti                                  973Building/Use                              942Root/Sewer/Sidewalk Condition             836Derelict Vehicle                          803                                        ...Miscellaneous Categories                    5Posting Advertisement                       5Fire Alarm - Modification                   5Poison Ivy                                  5Internal Code                               5Illegal Animal Sold                         4Transportation Provider Complaint           4Special Natural Area District (SNAD)        4Ferry Complaint                             4Fire Alarm - Replacement                    3Invitation                                  3Illegal Fireworks                           3Adopt-A-Basket                              3Window Guard                                2Opinion for the Mayor                       2DFTA Literature Request                     2Public Assembly                             2Legal Services Provider Complaint           2Misc. Comments                              2DHS Income Savings Requirement              1Tunnel Condition                            1DWD                                         1Municipal Parking Facility                  1X-Ray Machine/Equipment                     1Ferry Permit                                1Highway Sign - Damaged                      1Snow                                        1Stalled Sites                               1Trans Fat                                   1Open Flame Permit                           1Name: Complaint Type, Length: 165, dtype: int64HEATING                   14200GENERAL CONSTRUCTION       7471Street Light Condition     7117DOF Literature Request     5797PLUMBING                   5373PAINT - PLASTER            5149Blocked Driveway           4590NONCONST                   3998Street Condition           3473Illegal Parking            3343Name: Complaint Type, dtype: int64

哈哈,聪明的你一定想到上一节说的绘图,是的,咱们可以把top10画出来。

complaints_counts[:10].plot(figsize=(20,6)) #默认是折线图plt.show()

2.Python数据分析(数据选择与分析及折线图柱状图Selecting_data_and_analysis_part1)

complaints_counts[:10].plot(kind='bar') # 柱状图plt.show()

2.Python数据分析(数据选择与分析及折线图柱状图Selecting_data_and_analysis_part1)

I love you because you are the last person I want to talk to before going to bed at night.

我爱你是因为你是我晚上睡睡前最后一个想说话的人。

—《飞屋环游记》

数据链接:https://pan.baidu.com/s/1BX9z2WeAHrA0hduuf1OD0A
提取码:o2o8
来自七月在线数据挖掘算法
XiangLin

本文分享自微信公众号 - 五角钱的程序员(xianglin965)。
如有侵权,请联系 support@oschina.cn 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。

点赞
收藏
评论区
推荐文章
皕杰报表之柱状图
1.当我们想设置柱状图时,可以在皕杰报表内,鼠标右键设置类型选择图表类型,鼠标双击图表,选择柱状图和图标模式普通柱状图。可以设置为水平方向。2.选择数据设定,在‘分类轴’和‘系列’中分别设定其值或者表达式。3.选择显示格式,一般图表包括图表区,标题与图例,X轴,Y轴和警戒线。图表颜色:设置图表数据区以外的背景色和字体颜色。数据区颜色:设置数据区内的背景颜色和
Aidan075 Aidan075
3年前
分享5个高效的pandas函数!
熟练掌握pandas函数都能帮我们在数据分析过程中节省时间。pandas还有很多让人舒适的用法,这次就为大家介绍5个pandas函数!本文来源towardsdatascience,作者SonerYıldırım,由Python大数据分析编译。1\.explodeexplode用于将一行数据展开成多行。比如说dataframe中某一行其中一个元素包含多个同
Stella981 Stella981
3年前
Deploy Python Django Web Application with UWSGI and Nginx
DeployPythonDjangoWebApplicationwithUWSGIandNginx1.InstallPackages2.ConfigureuWSGI2.1Loadingconfigurationfiles2.2Magicvariables2.3Placeholders2.4Placeholdersmat
Stella981 Stella981
3年前
Python3:sqlalchemy对mysql数据库操作,非sql语句
Python3:sqlalchemy对mysql数据库操作,非sql语句python3authorlizmdatetime2018020110:00:00coding:utf8'''
Wesley13 Wesley13
3年前
VISTA Enhancer Browser
微信公众号:生物信息学起步如果觉得对你有帮助,欢迎关注/转发/分享\1\内容目录1、目的2、实验数据2.1候选增强子识别2.2转基因小鼠分析2.3注释3、搜索数据库3.1概括3.2高级搜索3.3搜索结果3.4数据集页面4\.Gallery5\.教程6\.试剂和胚胎可用性原文链接1、目的
Wesley13 Wesley13
3年前
03.Android崩溃Crash库之ExceptionHandler分析
目录总结00.异常处理几个常用api01.UncaughtExceptionHandler02.Java线程处理异常分析03.Android中线程处理异常分析04.为何使用setDefaultUncaughtExceptionHandler前沿上一篇整体介绍了crash崩溃
Wesley13 Wesley13
3年前
vscode(Visual Studio Code)的配置
<!TOC1\.前言1.1.如何安装主题、图标以及各种辅助插件2\.主题及图标2.1.OneDarkPro2.2.DraculaOffical2.3.AtomOneDarkTheme2.4.VSCodeGr
Stella981 Stella981
3年前
Linux ReviewBoard安装与配置
目录0\.引言1\.安装步骤2\.配置站点2.1创建数据库2.2开始安装2.3修改文件访问权限2.4Web服务器配置2.5修改django相关配置正文回到顶部(https://www.oschi
Wesley13 Wesley13
3年前
MySQL企业版之数据脱敏功能
利用企业级特性给敏感数据打码。1\.插件安装2\.数据打码插件应用2.1隐藏重要数据2.2生成随机数据并打码2.3基于字典生成随机值2.4其他要注意的地方3\.总结4\.延伸阅读MySQL企业版从8.0.13开始,新增一个插件叫做DataMaskingandDeIdentification,我将其简
京东云开发者 京东云开发者
12个月前
达达埋点迁移京东子午线实践 | 京东云技术团队
一、概述1.项目价值及成果使用集团的统一埋点采集能力和埋点平台,完成达达7条业务线共43个站点应用的埋点迁移,降低自研采集工具和平台的研发投入和机器成本,打通数据链路,创造更多的数据分析价值。具体降本增效价值如下:1.1数据分析价值:与京东流量数据打通,拉