Im trying to create an excel file with pandas for a database I have generated.
I have tried both:
import pandas as pd
# write database to excel
df = pd.DataFrame(database)
# Create a Pandas Excel writer using XlsxWriter as the engine.
writer = pd.ExcelWriter('fifa19.xlsx', engine='xlsxwriter')
# Convert the dataframe to an XlsxWriter Excel object.
df.to_excel(writer, sheet_name='Sheet1')
# Close the Pandas Excel writer and output the Excel file.
writer.save()
as well as:
import pandas as pd
df = pd.DataFrame(database).T
df.to_excel('database.xls')
However, none of the options generate an excel file. Database is a dictionary.
os.getcwd()
-- perhaps you're looking in the wrong place?os.chdir
to change the working directory, but depending on how you're using this, chances are that you're better off by specifying the absolute path in the argument toExcelWriter
.writer = pd.ExcelWriter('/home/anton/newoutput.xlsx')
, however you don't need to mentionengine='xlsxwriter'
in the newwer version of pandas.