<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def median(timeseries, segmentlength, **kwargs):
 """Calculate a PSD using Welch's method with a median average """

    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)