I created dataframe, and use df.to_excel('test.xlsx', index=False)
. I can see my python code generated excel file in a local directory, but problem is I can't open it with excel.
I also added more parameter engine='xlsxwriter'
in df.to_excel('test.xlsx', index=False)
. Thus I tried
df.to_excel('test.xlsx', index=False, engine='xlsxwriter')
, but didn't work out.
import pandas as pd
import numpy as np
df = pd.read_csv('123.tsv', sep='\t')
df['M'] = df['M'].astype(str)
m = df.M.str.split(',', expand=True).values.ravel()
df = df.dropna()
df = df[~df.M.str.contains("@")]
df = df.drop_duplicates()
df.to_excel('123.xlsx', index=False, engine='xlsxwriter')
expected outcome: just wanna open 123.xlsx in excel
actual result:
Excel cannot open the file '123.xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file. (Mac Excel 2016)