Skip to content

Instantly share code, notes, and snippets.

@dengjonathan
Last active April 24, 2016 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dengjonathan/34e6b0e3ff7da66c1c98adf09b7af96b to your computer and use it in GitHub Desktop.
Save dengjonathan/34e6b0e3ff7da66c1c98adf09b7af96b to your computer and use it in GitHub Desktop.
def csv2dataframe(fileobj):
"""Returns csv file as a pandas dataframe"""
with open(fileobj, 'r') as f:
return pd.read_csv(f, header=0)
# read all csv files to DataFrame objects and append to list then concatenate all dfs in list into one 'super_df'
df_list = [csv2dataframe(file) for file in os.listdir(os.getcwd()) if file.endswith('.csv')]
ranger_classes = [1, 3, 4, 5, 6, 7, 8, 9, 10, 11]
super_df = pd.concat(df_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment