-
-
Save jeffatennis/42c3717220f649199591 to your computer and use it in GitHub Desktop.
Revisions
-
Ryan Hill revised this gist
Sep 18, 2015 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,9 @@ ''' def dbf2DF(dbfile, upper=True): #Reads in DBF files and returns Pandas DF db = ps.open(dbfile) #Pysal to open DBF d = {col: db.by_col(col) for col in db.header} #Convert dbf to dictionary #pandasDF = pd.DataFrame(db[:]) #Convert to Pandas DF pandasDF = pd.DataFrame(d) #Convert to Pandas DF if upper == True: #Make columns uppercase if wanted pandasDF.columns = map(str.upper, db.header) db.close() -
Ryan Hill created this gist
Sep 16, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ import pysal as ps import pandas as pd ''' Arguments --------- dbfile : DBF file - Input to be imported upper : Condition - If true, make column heads upper case ''' def dbf2DF(dbfile, upper=True): #Reads in DBF files and returns Pandas DF db = ps.open(dbfile) #Pysal to open DBF pandasDF = pd.DataFrame(db[:]) #Convert to Pandas DF if upper == True: #Make columns uppercase if wanted pandasDF.columns = map(str.upper, db.header) db.close() return pandasDF