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

CHORE: Fix PerformanceWarning in pivot combine stage #747

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
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
11 changes: 7 additions & 4 deletions python/xorbits/_mars/dataframe/base/pivot.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,14 @@
input_data = ctx[op.inputs[0].key]
out = op.outputs[0]

for dtype in op.output_columns:
if dtype not in input_data.dtypes.index:
input_data[dtype] = np.nan
dtypes = [
dtype for dtype in op.output_columns if dtype not in input_data.dtypes.index
]
nan_data = pd.DataFrame(
{col: [np.nan] for col in dtypes}, index=input_data.index
)

ctx[out.key] = input_data
ctx[out.key] = pd.concat([input_data, nan_data], axis=1)

Check warning on line 77 in python/xorbits/_mars/dataframe/base/pivot.py

View check run for this annotation

Codecov / codecov/patch

python/xorbits/_mars/dataframe/base/pivot.py#L77

Added line #L77 was not covered by tests

@classmethod
def execute(cls, ctx: Union[dict, Context], op: "DataFramePivot"):
Expand Down
Loading