Import agate, python based data analysis
In [1]:
import agate
In [2]:
wells97 = agate.Table.from_csv('wells1997.csv')
wells02 = agate.Table.from_csv('wells2002.csv')
wells07 = agate.Table.from_csv('wells2007.csv')
wells12 = agate.Table.from_csv('wells2012.csv')
def upperCase(row):
return row['Countyname'].upper()
clean_well97 = wells97.compute([
('clean_County', agate.Formula(agate.Text(), upperCase))
]).select(['clean_County', 'Wells'])
clean_well02 = wells02.compute([
('clean_County', agate.Formula(agate.Text(), upperCase))
]).select(['clean_County', 'Wells'])
clean_well07 = wells07.compute([
('clean_County', agate.Formula(agate.Text(), upperCase))
]).select(['clean_County', 'Wells'])
clean_well12 = wells12.compute([
('clean_County', agate.Formula(agate.Text(), upperCase))
]).select(['clean_County', 'Wells'])
In [3]:
print(clean_well97)
In [4]:
acres97 = agate.Table.from_csv('irrigatedAcres1997.csv')
acres02 = agate.Table.from_csv('irrigatedAcres2002.csv')
acres07 = agate.Table.from_csv('irrigatedAcres2007.csv')
acres12 = agate.Table.from_csv('irrigatedAcres2012.csv')
In [5]:
print(acres97)
acres97.print_table(10)
In [6]:
total97 = clean_well97.join(acres97, 'clean_County', 'County', inner=True)
print(len(total97.rows))
total97.to_csv('wells_acres97.csv')
total02 = clean_well02.join(acres02, 'clean_County', 'County', inner=True)
print(len(total02.rows))
total02.to_csv('wells_acres02.csv')
total07 = clean_well07.join(acres07, 'clean_County', 'County', inner=True)
print(len(total07.rows))
total07.to_csv('wells_acres07.csv')
total12 = clean_well12.join(acres12, 'clean_County', 'County', inner=True)
print(len(total12.rows))
total12.to_csv('wells_acres12.csv')
In [ ]: