I am new to Python. I am working on a large analytic program, and this is a snippet of it. Right now, this snippet exports multiple excel files. Is it possible to save what is done per loop on a sheet within a single excel document? So basically right now, it exports 5 files, rather than exporting 5 separate files, can I use this loop and export 1 file, that has 5 sheets?
x = 0
y = 0
#these are empty variables for the while loop
#while loop that loops up to the system amount
#breaks up df into systems
#exports excel for each system
while x < int(SystemCount):
x += 1
y += 1
System = minus4[minus4['System'] == "System " + str(y)]
System.to_excel('U4Sys' + str(y) + '.xlsx', sheet_name='sheet1', index=False)
print(System.head())
the print at the end prints this
email System
test1@test.com System 1
test2@test.com System 1
test3@test.com System 1
test4@test.com System 1
test5@test.com System 1
email System
test1@test.com System 2
test2@test.com System 2
test3@test.com System 2
test4@test.com System 2
test5@test.com System 2
email System
test1@test.com System 3
test2@test.com System 3
test3@test.com System 3
test4@test.com System 3
test5@test.com System 3
Thank you for taking your time to read this!