Skip to content

better error message for to_datetime #4928

Closed
@cpcloud

Description

@cpcloud

cc @danbirken

In [2]: to_datetime([1,'1'])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-1d4cd9e078aa> in <module>()
----> 1 to_datetime([1,'1'])

/home/phillip/Documents/code/py/pandas/pandas/tseries/tools.pyc in to_datetime(arg, errors, dayfirst, utc, box, format, coerce, unit)
    137         return Series(values, index=arg.index, name=arg.name)
    138     elif com.is_list_like(arg):
--> 139         return _convert_listlike(arg, box=box)
    140
    141     return _convert_listlike(np.array([ arg ]), box=box)[0]

/home/phillip/Documents/code/py/pandas/pandas/tseries/tools.pyc in _convert_listlike(arg, box)
    117                 result = tslib.array_to_datetime(arg, raise_=errors == 'raise',
    118                                                  utc=utc, dayfirst=dayfirst,
--> 119                                                  coerce=coerce, unit=unit)
    120             if com.is_datetime64_dtype(result) and box:
    121                 result = DatetimeIndex(result, tz='utc' if utc else None)

/home/phillip/Documents/code/py/pandas/pandas/tslib.so in pandas.tslib.array_to_datetime (pandas/tslib.c:16487)()

TypeError: object of type 'int' has no len()

Metadata

Metadata

Assignees

No one assigned

    Labels

    DatetimeDatetime data dtypeDocsError ReportingIncorrect or improved errors from pandas

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions