<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def mutating_join(*args, **kwargs):
 """ generic function for mutating dplyr-style joins """

  # candidate for improvement
  left = args[0]
  right = args[1]
  if 'by' in kwargs:
    left_cols, right_cols = get_join_cols(kwargs['by'])
  else:
    left_cols, right_cols = None, None
  if 'suffixes' in kwargs:
    dsuffixes = kwargs['suffixes']
  else:
    dsuffixes = ('_x', '_y')
  if left._grouped_on:
    outDf = (DplyFrame((left >> ungroup())
                       .merge(right, how=kwargs['how'], left_on=left_cols, 
                              right_on=right_cols, suffixes=dsuffixes))
             .regroup(left._grouped_on))
  else:
    outDf = DplyFrame(left.merge(right, how=kwargs['how'], left_on=left_cols, 
                                 right_on=right_cols, suffixes=dsuffixes))
  return outDf