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: Series(dt64, dtype="Sparse[object]") #38508

Closed

Conversation

jbrockmendel
Copy link
Member

  • closes #xxxx
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

As a side effect of fixing astype_nansafe, we can rip some code out of Block._astype.

arr2 = arr.view("m8[ns]")

ser = Series(arr, dtype="Sparse[object]")
assert isinstance(ser[0], Timestamp)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why wouldn't these be Sparse[datetime64[ns]] ? (and equiv for timedelta). do we actually have a usecase for embedding non-object dtypes here? I think this something that we should limit (as we do coercion on non-sparse things if they are datetimelike already this is a big change).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure i understand the question. are you asking why L1521 isnt ser = Series(arr, dtype="Sparse[datetime64[ns]]")?

Looking at the non-sparse, case Series(arr, dtype=object)[0] returns a pydatetime object, so i guess its OK that Sparse[object] does the same.

Really the motivation is to make astype_nansafe with dt64 data behave the same as DatetimeArray.astype and Block._astype so we can share more.

@jreback jreback added Dtype Conversions Unexpected or buggy dtype conversions Sparse Sparse Data Type labels Dec 16, 2020
@jbrockmendel jbrockmendel deleted the bug-nansafe-dt64-object branch December 16, 2020 17:40
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 Sparse Sparse Data Type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants