code: def median(self):
          
          self._prep_pandas_groupby()
          return DataFrame.fromDataFrameRDD(
              self._regroup_mergedRDD().values().map(
                  lambda x: x.median()), self.sql_ctx)
docs: Compute median of groups, excluding missing values.
  
          For multiple groupings, the result index will be a MultiIndex.