Import agate, the very neat data program
In [1]:
import agate
Import in the natural amenities file forcing some categories to be text to ensure that leading zeros are lost
In [2]:
text = agate.Text()
tester = agate.TypeTester(force={
'FIPS': text,
'CombinedFIPS': text,
})
natural = agate.Table.from_csv('naturalamenities.csv', column_types=tester)
Let's see what columns are in the table
In [3]:
print(natural)
Order the counties by the natural amenity scale and only select the county, state and scale amount columns
In [6]:
bottom = natural.order_by('NaturalAmenityScale').select([
'County name', 'STATE', 'NaturalAmenityScale'
])
Let's see the 50 lowest scoring counties. You'll undoubtedly notice that South Dakota isn't featured once.
In [8]:
bottom.print_table(50)
Let's print out an overall csv with only the FIPS and amenity scale so I can create a QGIS map.
In [24]:
naturals = natural.select([
'FIPS', 'NaturalAmenityScale'
])
naturals.to_csv('natural-map.csv')