Skip to content

BUG: Series(index=[]) should have dtype=object #49574

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

Merged
merged 4 commits into from
Nov 9, 2022

Conversation

topper-123
Copy link
Contributor

No doc entry is needed, because this only fixes a corner case of #49342.

@topper-123 topper-123 force-pushed the empty_series_with_index_dtype branch from b75bfe9 to cf220db Compare November 8, 2022 08:55
@topper-123
Copy link
Contributor Author

The failed check looks unrelated.

@mroeschke mroeschke added Series Series data structure Constructors Series/DataFrame/Index/pd.array Constructors labels Nov 8, 2022
@@ -511,7 +511,10 @@ def _init_dict(
elif index is not None:
# fastpath for Series(data=None). Just use broadcasting a scalar
# instead of reindexing.
values = na_value_for_dtype(pandas_dtype(dtype), compat=False)
if len(index) or dtype is not None:
Copy link
Member

Choose a reason for hiding this comment

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

Do we know that index is list-like by the time we get here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, partly from the type hints in this method and partly because of the index = ensure_index(index) part in the __init__ method.

@mroeschke
Copy link
Member

Thanks for catching this. One question otherwise LGTM

@mroeschke mroeschke added this to the 2.0 milestone Nov 9, 2022
@mroeschke mroeschke merged commit 7005f8c into pandas-dev:main Nov 9, 2022
@mroeschke
Copy link
Member

Thanks @topper-123

phofl pushed a commit to phofl/pandas that referenced this pull request Nov 9, 2022
* BUG: Series(index=[]) should have dtype=object

* parametrize tests

* accept dtype

* fix

Co-authored-by: Terji Petersen <[email protected]>
@topper-123 topper-123 deleted the empty_series_with_index_dtype branch November 9, 2022 18:17
codamuse pushed a commit to codamuse/pandas that referenced this pull request Nov 12, 2022
* BUG: Series(index=[]) should have dtype=object

* parametrize tests

* accept dtype

* fix

Co-authored-by: Terji Petersen <[email protected]>
mliu08 pushed a commit to mliu08/pandas that referenced this pull request Nov 27, 2022
* BUG: Series(index=[]) should have dtype=object

* parametrize tests

* accept dtype

* fix

Co-authored-by: Terji Petersen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Constructors Series/DataFrame/Index/pd.array Constructors Series Series data structure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Series(index=[]) has dtype float64, should be object
2 participants