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: .loc assignment of datetime with tz is coercing to naive #11365

Closed
jreback opened this issue Oct 18, 2015 · 2 comments

Comments

Projects
None yet
3 participants
@jreback
Copy link
Contributor

commented Oct 18, 2015

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]

@taeold

This comment has been minimized.

Copy link
Contributor

commented Oct 19, 2015

@jreback took a stab at the bug outlined above. However, I'm not sure what exactly is meant by

this is also realized to #11351 [4]

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

This comment has been minimized.

Copy link
Contributor Author

commented Oct 19, 2015

@taeold yes that is fine. These are independent, just linking them really.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.