Skip to content

[#16737] Index type for Series with empty data #32053

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

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
silenced some more warnings
  • Loading branch information
SaturnFromTitan committed Apr 22, 2020
commit 6d30bce6ef443cd8fef0c30f2fb4c560c09841da
6 changes: 4 additions & 2 deletions pandas/tests/groupby/test_grouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
date_range,
)
import pandas._testing as tm
from pandas.core.construction import create_series_with_explicit_index
from pandas.core.groupby.grouper import Grouping

# selection
Expand Down Expand Up @@ -637,11 +638,12 @@ def test_evaluate_with_empty_groups(self, func, expected):

def test_groupby_empty(self):
# https://github.com/pandas-dev/pandas/issues/27190
s = pd.Series([], name="name", dtype="float64")
s = create_series_with_explicit_index([], name="name", dtype="float64")
gr = s.groupby([])

result = gr.mean()
tm.assert_series_equal(result, s)
expected = pd.Series([], name="name", dtype="float64", index=pd.RangeIndex(0))
tm.assert_series_equal(result, expected)

# check group properties
assert len(gr.grouper.groupings) == 1
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/io/parser/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pandas.core.dtypes.dtypes import CategoricalDtype

import pandas as pd
from pandas import Categorical, DataFrame, Index, MultiIndex, Series, Timestamp, concat
from pandas import Categorical, DataFrame, Index, MultiIndex, Timestamp, concat
import pandas._testing as tm
from pandas.core.construction import create_series_with_explicit_index

Expand Down Expand Up @@ -435,7 +435,7 @@ def test_empty_with_dup_column_pass_dtype_by_indexes(all_parsers):
expected = concat(
[
create_series_with_explicit_index([], name="one", dtype="u1"),
Series([], name="one.1", dtype="f"),
create_series_with_explicit_index([], name="one.1", dtype="f"),
],
axis=1,
)
Expand All @@ -452,7 +452,7 @@ def test_empty_with_dup_column_pass_dtype_by_indexes_raises(all_parsers):
expected = concat(
[
create_series_with_explicit_index([], name="one", dtype="u1"),
Series([], name="one.1", dtype="f"),
create_series_with_explicit_index([], name="one.1", dtype="f"),
],
axis=1,
)
Expand Down