Skip to content

DOC/ERR: update error message / doc-string for to_datetime with non-convertible object and unit kw #14350

Closed
@julienvienne

Description

@julienvienne

A small, complete example of the issue

import pandas as pd
pd.to_datetime(datetime.datetime(2016,1,1), unit='s')
Traceback (most recent call last):
  File "/home/julienv/.pycharm_helpers/pydev/pydevd_exec2.py", line 3, in Exec
    exec(exp, global_vars, local_vars)
  File "<input>", line 1, in <module>
  File "/usr/local/lib/python3.4/dist-packages/pandas/util/decorators.py", line 91, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/pandas/tseries/tools.py", line 424, in to_datetime
    return _convert_listlike(np.array([arg]), box, format)[0]
  File "/usr/local/lib/python3.4/dist-packages/pandas/tseries/tools.py", line 330, in _convert_listlike
    errors=errors)
  File "pandas/tslib.pyx", line 2144, in pandas.tslib.array_with_unit_to_datetime (pandas/tslib.c:39248)
  File "pandas/tslib.pyx", line 2255, in pandas.tslib.array_with_unit_to_datetime (pandas/tslib.c:38492)
ValueError: non convertible value 2016-01-01 00:00:00with the unit 's'

Expected Output

Timestamp('2016-01-01 00:00:00')

Output of pd.show_versions()

pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.4.3.final.0
python-bits: 64
OS: Linux
OS-release: 3.13.0-96-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: fr_FR.UTF-8
LOCALE: fr_FR.UTF-8

pandas: 0.19.0
nose: None
pip: 1.5.4
setuptools: 3.3
Cython: 0.20.1post0
numpy: 1.11.2
scipy: 0.18.1
statsmodels: None
xarray: None
IPython: None
sphinx: 1.2.2
patsy: None
dateutil: 2.5.3
pytz: 2016.7
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.999
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: 2.5.3 (dt dec pq3 ext)
jinja2: 2.7.3
boto: None
pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions