Reading 0 from pandas.dataframe - treated as string type by Cell.py
Created originally on Bitbucket by archit_jain (Archit Jain)
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 cell.py file returning a string datatype for the value. It could be corrected by changing the order of inference of the correct data type in cell.py/data_type_for_value(self, 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.