I have a pandas dataframe as below:
header = [np.array(['location','location','location','location2','location2','location2']),
np.array(['S1','S2','S3','S4','S5','S6'])]
df = pd.DataFrame(np.random.randn(5, 6), columns = header )
df
I want to export my dataframe to an excel sheet ignoring the index. Here is my code which exports my dataframe to excel spreadsheet but with index. when I am using the parameter, index = False, It gives me an error.
# output all the consolidated input to an excel sheet
out_file_name = os.path.join(folder_location, "templates", future_template)
writer = pd.ExcelWriter(out_file_name, engine='xlsxwriter')
# Write each dataframe to a different worksheet.
df.to_excel(writer, sheet_name='Ratings Inputs')
# Close the Pandas Excel writer and output the Excel file.
writer.save()