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

Series[datetime64[ns, tz]].__setitem__ fails to coerce for ndarray value #23932

Closed
TomAugspurger opened this issue Nov 26, 2018 · 2 comments · Fixed by #24024
Closed

Series[datetime64[ns, tz]].__setitem__ fails to coerce for ndarray value #23932

TomAugspurger opened this issue Nov 26, 2018 · 2 comments · Fixed by #24024
Labels
Dtype Conversions Unexpected or buggy dtype conversions ExtensionArray Extending pandas with custom dtypes or arrays. Indexing Related to indexing on series/frames, not to indexes themselves Timeseries

Comments

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Nov 26, 2018

What's the expected output for

In [9]: a = pd.Series(pd.DatetimeIndex(['2000', '2000'], tz="UTC"))

In [10]: a.loc[:] = np.array([pd.Timestamp('2000', tz="UTC")] * 2)

On master, we coerce self to object and then set.

In [11]: a
Out[11]:
0    2000-01-01 00:00:00+00:00
1    2000-01-01 00:00:00+00:00
dtype: object

Should we instead coerce value, rather than self?

@jbrockmendel
Copy link
Member

We should certainly at least try

@TomAugspurger TomAugspurger added Timeseries Indexing Related to indexing on series/frames, not to indexes themselves Dtype Conversions Unexpected or buggy dtype conversions ExtensionArray Extending pandas with custom dtypes or arrays. labels Nov 27, 2018
@TomAugspurger
Copy link
Contributor Author

TomAugspurger commented Nov 27, 2018

FYI, I have this working on my all-in-one branch (hoping to have a PR tomorrow).

In [4]: a.loc[:] = np.array([pd.Timestamp('2000', tz="UTC")] * 2)

In [5]: a
Out[5]:
0    2000-01-01 00:00:00+00:00
1    2000-01-01 00:00:00+00:00
dtype: datetime64[ns, UTC]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions ExtensionArray Extending pandas with custom dtypes or arrays. Indexing Related to indexing on series/frames, not to indexes themselves Timeseries
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants