Skip to content

Commit

Permalink
fix pandas 2.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ChengjieLi28 committed Sep 21, 2023
1 parent 863f7a7 commit b990ca5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
19 changes: 8 additions & 11 deletions python/xorbits/_mars/dataframe/base/tests/test_base_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -1729,12 +1729,10 @@ def test_value_counts_execution(setup):
r = series.value_counts()
pd.testing.assert_series_equal(r.execute().fetch(), s.value_counts())

# pandas issue: https://github.com/pandas-dev/pandas/issues/54857
if pd.__version__ != "2.1.0":
r = series.value_counts(bins=5, normalize=True)
pd.testing.assert_series_equal(
r.execute().fetch(), s.value_counts(bins=5, normalize=True)
)
r = series.value_counts(bins=5, normalize=True)
pd.testing.assert_series_equal(
r.execute().fetch(), s.value_counts(bins=5, normalize=True)
)

# test multi chunks
series = from_pandas_series(s, chunk_size=30)
Expand All @@ -1746,11 +1744,10 @@ def test_value_counts_execution(setup):
pd.testing.assert_series_equal(r.execute().fetch(), s.value_counts(normalize=True))

# test bins and normalize
if pd.__version__ != "2.1.0":
r = series.value_counts(method="tree", bins=5, normalize=True)
pd.testing.assert_series_equal(
r.execute().fetch(), s.value_counts(bins=5, normalize=True)
)
r = series.value_counts(method="tree", bins=5, normalize=True)
pd.testing.assert_series_equal(
r.execute().fetch(), s.value_counts(bins=5, normalize=True)
)


def test_astype(setup):
Expand Down
3 changes: 3 additions & 0 deletions python/xorbits/_mars/dataframe/base/value_counts.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ def execute(cls, ctx, op: "DataFrameValueCounts"):
# convert CategoricalDtype which generated in `cut`
# to IntervalDtype
result.index = result.index.astype("interval")
# index name changed since pandas 2.1.1
if pd_release_version >= (2, 1, 1):
result.index.name = None

Check warning on line 198 in python/xorbits/_mars/dataframe/base/value_counts.py

View check run for this annotation

Codecov / codecov/patch

python/xorbits/_mars/dataframe/base/value_counts.py#L198

Added line #L198 was not covered by tests
if op.nrows:
result = result.head(op.nrows)
result.name = op.outputs[0].name
Expand Down

0 comments on commit b990ca5

Please sign in to comment.