Merge and visualize stream cat files


In [1]:
#Import modules
import os, glob
import pandas as pd
from matplotlib import pyplot as plt

In [14]:
%matplotlib inline

In [2]:
#set the state
state = 'MD'

In [3]:
#Get the folder holding the files
stateFolder = 'StreamCat'+ os.sep + state+os.sep + '*.zip'
files = glob.glob(stateFolder)

In [4]:
#Create a dataframe of the first file, then loop through the others, merging them 
dfAll = pd.read_csv(files[0],index_col='COMID')
for f in files[1:]:
    df = pd.read_csv(f,index_col='COMID')
    dfAll = pd.merge(dfAll,df,how='outer',left_index=True,right_index=True)

In [17]:
x = dfAll.PctFrstLoss2001CatRp100.values
y = dfAll.PctFrstLoss2010CatRp100.values

In [19]:
plt.scatter(x,y,color='green')


Out[19]:
<matplotlib.collections.PathCollection at 0xae34fb0>