Skip to content

Commit

Permalink
Added meta to drop rows
Browse files Browse the repository at this point in the history
  • Loading branch information
argenisleon committed Nov 16, 2019
1 parent 2549e77 commit 983d244
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 8 additions & 2 deletions optimus/dataframe/rows.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,15 @@ def sort(col_sort):
"""
# If a list of columns names are given order this by desc. If you need to specify the order of every
# column use a list of tuples (col_name, "asc")
df = self

t = []
if is_list_of_str_or_int(col_sort):
for col_name in col_sort:
t.append(tuple([col_name, "desc"]))
col_sort = t

func = []

for cs in col_sort:
col_name = one_list_to_val(cs[0])
order = cs[1]
Expand All @@ -140,8 +141,13 @@ def sort(col_sort):
sort_func = F.asc
elif order == "desc":
sort_func = F.desc
else:
RaiseIt.value_error(sort_func, ["asc", "desc"])

func.append(sort_func(col_name))
df = self.sort(*func)
df = df.preserve_meta(self, Actions.SORT_ROW, col_name)

df = df.sort(*func)
return df

@add_attr(rows)
Expand Down
3 changes: 2 additions & 1 deletion optimus/helpers/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,13 @@ class Actions(Enum):
Z_SCORE = "z_score"
NEST = "nest"
UNNEST = "unnest"
DROP_ROW = "drop_row"
VALUES_TO_COLS = "values_to_cols"
SET = "set"
STRING_TO_INDEX = "string_to_index"
MIN_MAX_SCALER = "min_max_scaler"
MAX_ABS_SCALER = "max_abs_scaler"
DROP_ROW = "drop_row"
SORT_ROW = "sort_row"

@staticmethod
def list():
Expand Down

0 comments on commit 983d244

Please sign in to comment.