I am trying to save the output of the following code to a subdirectory:
for gp in g:
filename = gp[0] + '.csv'
print(filename)
gp[1].to_csv(filename)
I have created the subdirectory first:
os.makedirs('MonthlyDataSplit')
But I can't find any information as to how to use to_csv
to save to a subdirectory rather than the current directory. One approach I was thinking was to use the with "MonthlyDataSplit" open as directory
but I can only find the equivalent for opening a file in a subdirectory.