Skip to content

Data corruption during Excel export #10970

Closed
@bertrandhaut

Description

@bertrandhaut

In some case a DataFrame exported to excel present some bad values.
It's is not a problem of Excel reading (the data inside the sheet1.xml of the .xlsx file is also incorrect).

The same DataFrame exported to ".csv" is correct.

The problem could be "solved" by renaming the column header as [col-1, col-2,...]. Maybe an encoding problem ?

The issue is that there is no warning/error during the export. It's very easy to miss it.

To reproduce:

import pandas as pd

df = pd.read_pickle('problematic_df.pkl')
df.to_excel('problematic_df.xlsx')
df.to_csv('problematic_df.csv')

with the file available here: https://drive.google.com/file/d/0Bzz_ZaP_wS_HMFdlMkVzaTR0cjA/view?usp=sharing

Note that the content of cell M14 is different in both file (at least when run on my computer)

Using:

  • Python 3.4.3 |Anaconda 2.3.0 (64-bit)
  • pandas 0.16.2
  • Windows 7 64 bits

Metadata

Metadata

Assignees

No one assigned

    Labels

    IO Excelread_excel, to_excel

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions