A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/4229 below:

Inconsistent behavior initializing DatetimeIndex to tz with list/array of string times · Issue #4229 · pandas-dev/pandas · GitHub

Initializing a DatetimeIndex with a list of strings behaves differently than initializing with a numpy array of strings. To me these should behave the same and I personally like the list behavior better. My understanding of the tz argument to DatetimeIndex is that it is localizing rather than converting in which case the numpy array case is inconsistent. I don't think there should be an assumption made about the tz of the strings before indicating it by localizing.

>>> idx = ['11/10/2005 08:00:00','11/10/2005 09:00:00']
>>> DatetimeIndex(idx, tz='US/Eastern')
<class 'pandas.tseries.index.DatetimeIndex'>
[2005-11-10 08:00:00, 2005-11-10 09:00:00]
Length: 2, Freq: None, Timezone: US/Eastern
>>> import numpy as np
>>> idxnp = np.array(idx)
>>> DatetimeIndex(idxnp, tz='US/Eastern')
<class 'pandas.tseries.index.DatetimeIndex'>
[2005-11-10 03:00:00, 2005-11-10 04:00:00]
Length: 2, Freq: None, Timezone: US/Eastern

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4