Skip to content

Commit

Permalink
style and comments for window function
Browse files Browse the repository at this point in the history
  • Loading branch information
christinafan committed Jun 26, 2023
1 parent 429c309 commit fba5927
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions modin/core/dataframe/pandas/dataframe/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2016,13 +2016,14 @@ def window(

axis = Axis(axis)

# applies reduction function over entire virtual partition
def window_function_complete(virtual_partition):
virtual_partition_copy = virtual_partition.copy()
window_result = reduce_fn(virtual_partition_copy)
return window_result

# applies reduction function over one window of virtual partition
def window_function_partition(virtual_partition):

virtual_partition_copy = virtual_partition.copy()
window_result = reduce_fn(virtual_partition_copy)
return window_result.iloc[:, window_size - 1 : ] if axis == Axis.COL_WISE else window_result.iloc[window_size - 1: , :]
Expand All @@ -2037,8 +2038,8 @@ def window_function_partition(virtual_partition):
# partitions to join in virtual partition
parts_to_join = [starting_part] if (axis == Axis.ROW_WISE) else [[partition[0]] for partition in starting_part]

# used to determine if window continues into next partition or if we can create virtual partition
last_window_span = window_size - 1

k = i + 1

while (last_window_span > 0 and k < num_parts):
Expand Down Expand Up @@ -2073,6 +2074,7 @@ def window_function_partition(virtual_partition):
else:
reduce_result = [virtual_partition.apply(window_function_partition) for virtual_partition in virtual_partitions]

# append reduction result to results array
if axis == Axis.ROW_WISE:
results.append(reduce_result)
else:
Expand Down
3 changes: 1 addition & 2 deletions modin/core/storage_formats/pandas/query_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1806,8 +1806,7 @@ def rolling_aggregate(self, axis, rolling_args, func, *args, **kwargs):
if not center and isinstance(window, int):
return self.__constructor__(
self._modin_frame.window(
axis, window,
lambda df: df.rolling(*rolling_args).aggregate(func=func, *args, **kwargs)
axis, window, lambda df: df.rolling(*rolling_args).aggregate(func=func, *args, **kwargs)
)
)
else:
Expand Down

0 comments on commit fba5927

Please sign in to comment.