code: def _custom_rdd_reduce(self, reduce_func):
          
          def accumulating_iter(iterator):
              acc = None
              for obj in iterator:
                  if acc is None:
                      acc = obj
                  else:
                      acc = reduce_func(acc, obj)
              if acc is not None:
                  yield acc
          vals = self._rdd.mapPartitions(accumulating_iter).collect()
          return reduce(accumulating_iter, vals)
docs: Provides a custom RDD reduce which preserves ordering if the RDD has
          been sorted. This is useful for us because we need this functionality
          as many pandas operations support sorting the results. The standard
          reduce in PySpark does not have this property.  Note that when PySpark
          no longer does partition reduces locally this code will also need to
          be updated.