In [1]:
import pandas
In [8]:
a = pandas.read_csv('airports.csv')
a.head()
Out[8]:
id ident type name latitude_deg longitude_deg elevation_ft continent iso_country iso_region municipality scheduled_service gps_code iata_code local_code home_link wikipedia_link keywords
0 6523 00A heliport Total Rf Heliport 40.070801 -74.933601 11.0 NaN US US-PA Bensalem no 00A NaN 00A NaN NaN NaN
1 6524 00AK small_airport Lowell Field 59.949200 -151.695999 450.0 NaN US US-AK Anchor Point no 00AK NaN 00AK NaN NaN NaN
2 6525 00AL small_airport Epps Airpark 34.864799 -86.770302 820.0 NaN US US-AL Harvest no 00AL NaN 00AL NaN NaN NaN
3 6526 00AR heliport Newport Hospital & Clinic Heliport 35.608700 -91.254898 237.0 NaN US US-AR Newport no 00AR NaN 00AR NaN NaN NaN
4 322127 00AS small_airport Fulton Airport 34.942803 -97.818019 1100.0 NaN US US-OK Alex no 00AS NaN 00AS NaN NaN NaN
In [10]:
a['continent'].fillna('NA',inplace=True)
a.head()
Out[10]:
id ident type name latitude_deg longitude_deg elevation_ft continent iso_country iso_region municipality scheduled_service gps_code iata_code local_code home_link wikipedia_link keywords
0 6523 00A heliport Total Rf Heliport 40.070801 -74.933601 11.0 NA US US-PA Bensalem no 00A NaN 00A NaN NaN NaN
1 6524 00AK small_airport Lowell Field 59.949200 -151.695999 450.0 NA US US-AK Anchor Point no 00AK NaN 00AK NaN NaN NaN
2 6525 00AL small_airport Epps Airpark 34.864799 -86.770302 820.0 NA US US-AL Harvest no 00AL NaN 00AL NaN NaN NaN
3 6526 00AR heliport Newport Hospital & Clinic Heliport 35.608700 -91.254898 237.0 NA US US-AR Newport no 00AR NaN 00AR NaN NaN NaN
4 322127 00AS small_airport Fulton Airport 34.942803 -97.818019 1100.0 NA US US-OK Alex no 00AS NaN 00AS NaN NaN NaN
In [11]:
%pylab inline
Populating the interactive namespace from numpy and matplotlib
In [12]:
plot(a['longitude_deg'],a['latitude_deg'],'bo',alpha=0.05)
Out[12]:
[<matplotlib.lines.Line2D at 0x7f0e22fddb00>]
In [13]:
len(a)
Out[13]:
50926
In [14]:
# most northerly and southerly?
a['latitude_deg'].max(), a['latitude_deg'].min()
Out[14]:
(82.75, -90.0)
In [17]:
ilatmax = a['latitude_deg'].argmax()
a.iloc[ilatmax]
Out[17]:
id                                           320326
ident                                       CA-0605
type                                         closed
name                 Disraeli Inlet Water Aerodrome
latitude_deg                                  82.75
longitude_deg                                   -73
elevation_ft                                    NaN
continent                                        NA
iso_country                                      CA
iso_region                                    CA-NU
municipality                         Disraeli Inlet
scheduled_service                                no
gps_code                                        NaN
iata_code                                       NaN
local_code                                      SW6
home_link                                       NaN
wikipedia_link                                  NaN
keywords                                        NaN
Name: 13039, dtype: object
In [18]:
ielmax = a['elevation_ft'].argmax()
a.iloc[ielmax]
Out[18]:
id                                         35129
ident                                    IN-0001
type                                    heliport
name                 Siachen Glacier AFS Airport
latitude_deg                                35.5
longitude_deg                                 77
elevation_ft                               22000
continent                                     AS
iso_country                                   IN
iso_region                                 IN-JK
municipality                                 NaN
scheduled_service                             no
gps_code                                     NaN
iata_code                                    NaN
local_code                                   NaN
home_link                                    NaN
wikipedia_link                               NaN
keywords                                     NaN
Name: 23152, dtype: object
In [19]:
ielmin = a['elevation_ft'].argmin()
a.iloc[ielmin]
Out[19]:
id                                                               4421
ident                                                            LLMZ
type                                                   medium_airport
name                                              Bar Yehuda Airfield
latitude_deg                                                  31.3282
longitude_deg                                                 35.3886
elevation_ft                                                    -1266
continent                                                          AS
iso_country                                                        IL
iso_region                                                       IL-D
municipality                                                   Masada
scheduled_service                                                  no
gps_code                                                         LLMZ
iata_code                                                         MTZ
local_code                                                        NaN
home_link                                                         NaN
wikipedia_link       http://en.wikipedia.org/wiki/Bar_Yehuda_Airfield
keywords                                              Masada Airfield
Name: 29865, dtype: object
In [20]:
g = a.groupby('type')
g
Out[20]:
<pandas.core.groupby.DataFrameGroupBy object at 0x7f0e23e04518>
In [21]:
for name,item in g: print(name)
balloonport
closed
heliport
large_airport
medium_airport
seaplane_base
small_airport
In [22]:
g['id'].count()
Out[22]:
type
balloonport          20
closed             2341
heliport           9470
large_airport       574
medium_airport     4527
seaplane_base      1007
small_airport     32987
Name: id, dtype: int64
In [23]:
g.agg({'latitude_deg':[min,max],'elevation_ft':[min,max]})
Out[23]:
elevation_ft latitude_deg
min max min max
type
balloonport 37.0 5624.0 -35.194300 52.112201
closed -3.0 9228.0 -64.824000 82.750000
heliport -99.0 22000.0 -54.233548 81.697844
large_airport -11.0 10860.0 -43.489399 69.683296
medium_airport -1266.0 14219.0 -90.000000 82.517799
seaplane_base -1.0 4201.0 -41.008900 69.637000
small_airport -210.0 16200.0 -80.318298 81.600000
In [ ]: