Skip to content

Commit

Permalink
Merge branch 'main' into feat/from_export
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Dec 18, 2024
2 parents 32652bf + b48e2dc commit f636966
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
4 changes: 3 additions & 1 deletion python/xorbits/_mars/dataframe/datasource/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ def __call__(self, shape=None, chunk_size=None, inp=None, name=None, names=None)
None,
shape=shape,
dtype=self.dtype,
index_value=parse_index(self.data, store_data=self.store_data),
# `store_data=True` to make sure
# when the `to_pandas()` is called, we can get the actual pandas value.
index_value=parse_index(self.data, store_data=True),
name=name,
names=names,
raw_chunk_size=chunk_size,
Expand Down
31 changes: 30 additions & 1 deletion python/xorbits/core/tests/test_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,40 @@ def test_getitem(setup):
pd.testing.assert_frame_equal(result.to_pandas(), expected)


def test_column_index_setitem(setup):
import pandas as pd

from ... import pandas as xpd

data = {"a": [1, 2, 3], "b": [4, 5, 6]}
df = pd.DataFrame(data)
xdf = xpd.DataFrame(data)

xdf.columns = xpd.Index(["c1", "d1"])
df.columns = pd.Index(["c1", "d1"])
pd.testing.assert_frame_equal(xdf.to_pandas(), df)

xdf.columns = ["c2", "d2"]
df.columns = ["c2", "d2"]
pd.testing.assert_frame_equal(xdf.to_pandas(), df)

xdf.columns = pd.Index(["c3", "d3"])
df.columns = pd.Index(["c3", "d3"])
pd.testing.assert_frame_equal(xdf.to_pandas(), df)

xdf.index = ["x1", "y1", "z1"]
df.index = ["x1", "y1", "z1"]
pd.testing.assert_frame_equal(xdf.to_pandas(), df)

xdf.index = xpd.Index(["x2", "y2", "z2"])
df.index = pd.Index(["x2", "y2", "z2"])
pd.testing.assert_frame_equal(xdf.to_pandas(), df)


# TODO: process exit cause hang
# def test_execution_with_process_exit_message(mocker):
# import numpy as np
# from xoscar.errors import ServerClosed

# import xorbits
# import xorbits.remote as xr

Expand Down

0 comments on commit f636966

Please sign in to comment.