import pandas
a = pandas.read_csv('airports.csv')
a.head()
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 | 323361 | 00AA | small_airport | Aero B Ranch Airport | 38.704022 | -101.473911 | 3435.0 | NaN | US | US-KS | Leoti | no | 00AA | NaN | 00AA | NaN | NaN | NaN |
2 | 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 |
3 | 6525 | 00AL | small_airport | Epps Airpark | 34.864799 | -86.770302 | 820.0 | NaN | US | US-AL | Harvest | no | 00AL | NaN | 00AL | NaN | NaN | NaN |
4 | 6526 | 00AR | closed | Newport Hospital & Clinic Heliport | 35.608700 | -91.254898 | 237.0 | NaN | US | US-AR | Newport | no | NaN | NaN | NaN | NaN | NaN | 00AR |
a['continent'].fillna('NA',inplace=True)
a.head()
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 | 323361 | 00AA | small_airport | Aero B Ranch Airport | 38.704022 | -101.473911 | 3435.0 | NA | US | US-KS | Leoti | no | 00AA | NaN | 00AA | NaN | NaN | NaN |
2 | 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 |
3 | 6525 | 00AL | small_airport | Epps Airpark | 34.864799 | -86.770302 | 820.0 | NA | US | US-AL | Harvest | no | 00AL | NaN | 00AL | NaN | NaN | NaN |
4 | 6526 | 00AR | closed | Newport Hospital & Clinic Heliport | 35.608700 | -91.254898 | 237.0 | NA | US | US-AR | Newport | no | NaN | NaN | NaN | NaN | NaN | 00AR |
%pylab inline
Populating the interactive namespace from numpy and matplotlib
plot(a['longitude_deg'],a['latitude_deg'],'b.',alpha=0.05)
[<matplotlib.lines.Line2D at 0x112eb3828>]
len(a)
53459
# most northerly and southerly?
a['latitude_deg'].max(), a['latitude_deg'].min()
(82.75, -90.0)
ilatmax = a['latitude_deg'].argmax()
a.iloc[ilatmax]
/Users/drt/anaconda3/lib/python3.6/site-packages/ipykernel_launcher.py:1: FutureWarning: 'argmax' is deprecated. Use 'idxmax' instead. The behavior of 'argmax' will be corrected to return the positional maximum in the future. Use 'series.values.argmax' to get the position of the maximum now. """Entry point for launching an IPython kernel.
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: 13368, dtype: object
ielmax = a['elevation_ft'].argmax()
a.iloc[ielmax]
/Users/drt/anaconda3/lib/python3.6/site-packages/ipykernel_launcher.py:1: FutureWarning: 'argmax' is deprecated. Use 'idxmax' instead. The behavior of 'argmax' will be corrected to return the positional maximum in the future. Use 'series.values.argmax' to get the position of the maximum now. """Entry point for launching an IPython kernel.
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: 23744, dtype: object
ielmin = a['elevation_ft'].argmin()
a.iloc[ielmin]
/Users/drt/anaconda3/lib/python3.6/site-packages/ipykernel_launcher.py:1: FutureWarning: 'argmin' is deprecated. Use 'idxmin' instead. The behavior of 'argmin' will be corrected to return the positional minimum in the future. Use 'series.values.argmin' to get the position of the minimum now. """Entry point for launching an IPython kernel.
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: 30999, dtype: object
g = a.groupby('type')
g
<pandas.core.groupby.DataFrameGroupBy object at 0x1130cbb70>
for name,item in g: print(name)
balloonport closed heliport large_airport medium_airport seaplane_base small_airport
g['id'].count()
g.agg({'latitude_deg':[min,max],'elevation_ft':[min,max]})
latitude_deg | elevation_ft | |||
---|---|---|---|---|
min | max | min | max | |
type | ||||
balloonport | -35.194300 | 52.112201 | 37.0 | 5624.0 |
closed | -77.650008 | 82.750000 | -3.0 | 9869.0 |
heliport | -54.233548 | 81.697844 | -99.0 | 22000.0 |
large_airport | -43.489399 | 69.683296 | -11.0 | 10860.0 |
medium_airport | -90.000000 | 82.517799 | -1266.0 | 14219.0 |
seaplane_base | -41.008900 | 69.637000 | -1.0 | 4254.0 |
small_airport | -80.318298 | 81.600000 | -210.0 | 16200.0 |