Skip to content

Rounding valid timestamps near daylight savings jumps should not throw NonExistentTimeError #23324

Closed
@louispotok

Description

@louispotok

Code Sample, a copy-pastable example if possible

import pandas as pd

# valid time rounds incorrectly
pd.Timestamp('2018-03-11 01:59:00-0600', tz='America/Chicago').round(freq='5min')
# throws NonExistentTimeError: 2018-03-11 02:00:00
# should return pd.Timestamp('2018-03-11 03:00:00-0500', tz='America/Chicago')

Problem description

The timestamp is a valid time, so it should round to another valid timestamp. Specifically, it should round to the nearest 5min frequency valid time, which is the moment after the clock jumps.

Expected Output

pd.Timestamp('2018-03-11 03:00:00-0500', tz='America/Chicago')

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.6.6.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-1070-aws
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: C.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.22.0
pytest: None
pip: 18.1
setuptools: 39.2.0
Cython: None
numpy: 1.14.0
scipy: 1.1.0
pyarrow: 0.9.0
xarray: None
IPython: 6.5.0
sphinx: None
patsy: 0.5.0
dateutil: 2.7.3
pytz: 2018.6
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: 0.4.0
matplotlib: 2.1.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 1.0.1
sqlalchemy: 1.2.10
pymysql: None
psycopg2: 2.7.5 (dt dec pq3 ext lo64)
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions