Skip to content

Commit

Permalink
Fixes sort_values (#157)
Browse files Browse the repository at this point in the history
* Fixes sort_values

* formatting
  • Loading branch information
williamma12 authored and devin-petersohn committed Oct 12, 2018
1 parent a1f21f8 commit a770e15
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions modin/pandas/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -3575,24 +3575,30 @@ def sort_values(
broadcast_value_dict = {col: self[col] for col in by}
broadcast_values = pandas.DataFrame(broadcast_value_dict, index=self.index)
new_index = broadcast_values.sort_values(
by=by, axis=axis, ascending=ascending, kind=kind
by=by,
axis=axis,
ascending=ascending,
kind=kind,
na_position=na_position,
).index
return self.reindex(index=new_index)
return self.reindex(index=new_index, copy=not inplace)
else:
broadcast_value_list = [
to_pandas(self[row :: len(self.index)]) for row in by
]
index_builder = list(zip(broadcast_value_list, by))

broadcast_values = pandas.concat(
[row for row, idx in index_builder], copy=False
)
broadcast_values.columns = self.columns
new_columns = broadcast_values.sort_values(
by=by, axis=axis, ascending=ascending, kind=kind
by=by,
axis=axis,
ascending=ascending,
kind=kind,
na_position=na_position,
).columns

return self.reindex(columns=new_columns)
return self.reindex(columns=new_columns, copy=not inplace)

def sortlevel(
self, level=0, axis=0, ascending=True, inplace=False, sort_remaining=True
Expand Down

0 comments on commit a770e15

Please sign in to comment.