code: def median(timeseries, segmentlength, **kwargs):
      
      if scipy_version <= '1.1.9999':
          raise ValueError(
              "median average PSD estimation requires scipy >= 1.2.0",
          )
      kwargs.setdefault('average', 'median')
      return welch(timeseries, segmentlength, **kwargs)
docs: Calculate a PSD using Welch's method with a median average