Closed
Description
xref #12502 (example there as well)
xref #14148
In [3]: idx = pd.date_range('20130101',periods=3,tz='US/Eastern')
In [4]: df = DataFrame({'A' : [1,2,3]})
In [5]: df['B'] = idx
In [6]: df.dtypes
Out[6]:
A int64
B datetime64[ns, US/Eastern]
dtype: object
In [7]: df.loc[[True,False,True],'C'] = idx
In [8]: df
Out[8]:
A B C
0 1 2013-01-01 00:00:00-05:00 2013-01-01 05:00:00
1 2 2013-01-02 00:00:00-05:00 NaT
2 3 2013-01-03 00:00:00-05:00 2013-01-02 05:00:00
# C should be the same time zone
In [9]: df.dtypes
Out[9]:
A int64
B datetime64[ns, US/Eastern]
C datetime64[ns]
dtype: object
this is also realized to #11351 [4]
Activity
taeold commentedon Oct 19, 2015
@jreback took a stab at the bug outlined above. However, I'm not sure what exactly is meant by
The fix I've proposed here doesn't address the referenced bug (
AttributeError: 'numpy.ndarray' object has no attribute 'tz_localize'
). Is this sufficient fix for this issue or are you looking for a more general fix?jreback commentedon Oct 19, 2015
@taeold yes that is fine. These are independent, just linking them really.
BUG: .loc assignment of datetime with tz is coercing to naive pandas-…