Issue #24 invalid

Strings as objects in Pandas Dataframe

Anonymous created an issue

Hi :) I tried to convert a pandas dataframe using tabulate, but got this error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-142-57e44ebfe8ce> in <module>()
----> 1 print(tabulate.tabulate(df))

/Users/muela/anaconda/lib/python2.7/site-packages/tabulate.pyc in tabulate(tabular_data, headers, tablefmt, floatfmt, numalign, stralign, missingval)
    753     coltypes = list(map(_column_type, cols))
    754     cols = [[_format(v, ct, floatfmt, missingval) for v in c]
--> 755              for c,ct in zip(cols, coltypes)]
    756 
    757     # align columns

/Users/muela/anaconda/lib/python2.7/site-packages/tabulate.pyc in _format(val, valtype, floatfmt, missingval)
    446         return "{0}".format(val)
    447     elif valtype is _binary_type:
--> 448         return _text_type(val, "ascii")
    449     elif valtype is float:
    450         return format(float(val), floatfmt)

TypeError: coercing to Unicode: need string or buffer, float found

I played around a bit but I couldn't find out where it is coming from. Trying to tabulate the value array simlilarly failed, though it worked if I converted the value array to string.

Comments (4)

  1. t3kcit

    Any help would be much appreciated. Sorry, I forgot to log in before. I'm trying to create a minimal example but it seems non-trivial :-/

  2. Sergey Astanin repo owner

    Hi,

    pandas support is very new, with only few users testing it. Could you please give an example to reproduce the error. If you don't want to post the data online, you may send them privately to me, s.astanin@gmail.com. I'll look into this.

  3. Log in to comment