I'm trying to import multiple datasets into a single data frame through a function.
# function to import each of the new datasets
def csvImport(yearOfDataset):
import glob, os
for items in yearOfDataset:
# dataset name
ds = pd.concat(map(pd.read_csv, glob.glob(os.path.join("PSNI_StreetCrime_"+str(yearOfDataset)),"*.csv")))
I want to pass the argument to the function as follows, as it means I can call it quicker for the multiple folders I have; The folder name follow the pattern ChildFolder_YYYY
csvImport('2014')
When running the above, these are the errors being returned.
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-61-bba2086ac576> in <module>()
----> 1 csvImport('2014')
<ipython-input-56-0459a8272784> in csvImport(yearOfDataset)
2 def csvImport(yearOfDataset):
3 import glob, os
----> 4 sd = pd.concat(map(pd.read_csv, glob.glob(os.path.join("Datasets/PSNI_StreetCrime_"+yearOfDataset),"*.csv")))
TypeError: glob() takes 1 positional argument but 2 were given
I'm new to Pandas, and semi-new to Python so help would be greatly appreciated, the various changes I've tried have been unsuccessful.