Skip to content

BUG: Truncated "Y" conversion with to_timedelta #14024

Closed
@agartland

Description

@agartland

When converting a fractional year to a Timedelta object the float is truncated:

print pd.to_timedelta(1., unit='Y')
365 days 05:49:12

print pd.to_timedelta(1.5, unit='Y')
365 days 05:49:12

print pd.to_timedelta(0.5, unit='Y')
0 days 00:00:00

print pd.to_timedelta(0.9, unit='Y')
0 days 00:00:00

Using a float with the hour unit is OK:

print pd.to_timedelta(0.9, unit='H')
0 days 00:54:00

print pd.to_timedelta(1., unit='H')
0 days 01:00:00

Pandas version:

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.11.final.0
python-bits: 64
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 69 Stepping 1, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.18.1
nose: 1.3.7
pip: 8.1.1
setuptools: 21.2.1
Cython: 0.20.1
numpy: 1.11.0
scipy: 0.16.0
statsmodels: 0.7.0.dev-51faa1a
xarray: None
IPython: 4.2.0
sphinx: 1.2.2
patsy: 0.3.0
dateutil: 2.5.3
pytz: 2016.4
blosc: None
bottleneck: None
tables: 3.1.1
numexpr: 2.4.4
matplotlib: 1.5.1
openpyxl: 2.0.2
xlrd: 0.9.3
xlwt: 0.7.5
xlsxwriter: 0.5.5
lxml: 3.3.5
bs4: 4.3.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 0.9.4
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.28.0
pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions