Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: linspace behavior for date_range is incorrect when tz aware #20983

Closed
jschendel opened this issue May 8, 2018 · 0 comments · Fixed by #20988
Closed

BUG: linspace behavior for date_range is incorrect when tz aware #20983

jschendel opened this issue May 8, 2018 · 0 comments · Fixed by #20988
Labels
Bug Timezones Timezone data dtype
Milestone

Comments

@jschendel
Copy link
Member

Code Sample, a copy-pastable example if possible

xref #20846

In [2]: dti = pd.date_range('20180101', '20180103', periods=3, tz='US/Eastern')

In [3]: dti
Out[3]: DatetimeIndex(['2017-12-31', '2018-01-01', '2018-01-02'], dtype='datetime64[ns, US/Eastern]', freq=None)

In [4]: dti[0]
Out[4]: Timestamp('2017-12-31 19:00:00-0500', tz='US/Eastern')

Problem description

The dates in the date_range are not being localized correctly; the dates are being shifted back by the UTC offset, then having the timezone appended to the shifted back date.

Expected Output

I'd expect this to be identical to the equivalent non-linspace behavior call:

In [5]: dti2 = pd.date_range('20180101', periods=3, freq='D', tz='US/Eastern')

In [6]: dti2
Out[6]:
DatetimeIndex(['2018-01-01 00:00:00-05:00', '2018-01-02 00:00:00-05:00',
               '2018-01-03 00:00:00-05:00'],
              dtype='datetime64[ns, US/Eastern]', freq='D')

In [7]: dti2[0]
Out[7]: Timestamp('2018-01-01 00:00:00-0500', tz='US/Eastern', freq='D')

Output of pd.show_versions()

INSTALLED VERSIONS

commit: b3f07b2
python: 3.6.1.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 78 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None

pandas: 0.23.0rc2+23.gb3f07b2
pytest: 3.1.2
pip: 9.0.1
setuptools: 39.0.1
Cython: 0.28.2
numpy: 1.13.3
scipy: 1.0.0
pyarrow: 0.6.0
xarray: 0.9.6
IPython: 6.1.0
sphinx: 1.5.6
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: 1.2.1
tables: 3.4.2
numexpr: 2.6.4
feather: 0.4.0
matplotlib: 2.0.2
openpyxl: 2.4.8
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 0.9.8
lxml: 3.8.0
bs4: None
html5lib: 0.999
sqlalchemy: 1.1.13
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
fastparquet: 0.1.5
pandas_gbq: None
pandas_datareader: None

@jreback jreback added Bug Timezones Timezone data dtype labels May 9, 2018
@jreback jreback added this to the 0.23.0 milestone May 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants