Reading 0 from pandas.dataframe - treated as string type by

Issue #519 duplicate
Archit Jain
created an issue

I am trying to read a list of values from an excel file into Pandas.Dataframe and then write it value by value into another excel. The process throws up an error when it encouters a 0 value in the list "coercing to Unicode: need string or buffer, numpy.int64 found"

The error was due to the file returning a string datatype for the value. It could be corrected by changing the order of inference of the correct data type in, value) by moving this code elif not value: data_type = self.TYPE_STRING below elif isinstance(value, unicode) and self.RE_PATTERNS['numeric'].match(value): data_type = self.TYPE_NUMERIC elif not isinstance(value, unicode) and self.RE_PATTERNS['numeric'].match(str(value)): data_type = self.TYPE_NUMERIC

Another approach could have been by changing NUMERIC_TYPES to include numpy.int64.

Comments (2)

  1. CharlieC

    The problem is that Numpy types are not part of the standard library.

    We hoping to improve support for Pandas in the future but at the moment please use to to_excel method of a Pandas data frame.

  2. Log in to comment