In [90]:
import pandas as pd
In [91]:
pd.read_csv('data/jan1_7_09163500.txt', skiprows=26, delimiter='\t')
Out[91]:
In [92]:
data = pd.read_csv('data/jan1_7_09163500.txt', skiprows=26, delimiter='\t')
In [93]:
data.columns
Out[93]:
In [139]:
# this is a list
column_names = ['agency','station_number','date_time','timezone','discharge','d_status','stage','s_status']
In [95]:
data.columns = column_names
In [96]:
data.head()
Out[96]:
In [97]:
%matplotlib inline
from matplotlib import pyplot as plt
In [98]:
data['discharge'].plot()
Out[98]:
In [99]:
plt.plot(data['discharge'], data['stage'], 'k.')
Out[99]:
In [100]:
data['stage_meters'] = data['stage'] * 0.3048
In [101]:
data.head()
Out[101]:
In [102]:
column_names =['agency','station_number','date_time','timezone','discharge','d_status','stage','stage_meters','s_status']
In [103]:
data = data[column_names]
In [104]:
data.head()
Out[104]:
In [105]:
del data['s_status']
del data['d_status']
del data['agency']
data.head()
Out[105]:
In [162]:
# TALK HERE ABOUT INTEGER MULTIPLICATION
In [119]:
data['date_time'] = pd.to_datetime(data['date_time'])
In [143]:
data.plot(x = 'date_time', y = 'discharge')
Out[143]:
In [128]:
data.index = data['date_time']
In [138]:
fig, ax1 = plt.subplots()
ax2 = ax1.twinx()
ax1.plot(data['discharge'], 'g-')
ax2.plot(data['stage'], 'b-')
ax1.set_xlabel('date')
ax1.set_ylabel('discharge', color='g')
ax2.set_ylabel('stage', color='b')
plt.show()
In [163]:
# pull more data using web services
In [255]:
url = 'http://nwis.waterservices.usgs.gov/nwis/iv/?format=rdb&sites=06730200&startDT=2013-09-08&endDT=2013-09-14¶meterCd=00060'
data2 = pd.read_csv(url, comment='#', delimiter='\t', header=1)
In [256]:
data2.dtypes
Out[256]:
In [257]:
data2.head()
Out[257]:
In [ ]: