<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def qth_survival_time(q, survival_function, cdf=False):
 """ Returns the time when a single survival function reaches the qth percentile. Parameters q: float a float between 0 and 1 that represents the time when the survival function hit's the qth percentile. survival_function: Series or single-column DataFrame. cdf: boolean, optional When doing left-censored data, cdf=True is used. Returns ------- float See Also -------- qth_survival_times, median_survival_times """

    if type(survival_function) is pd.DataFrame:  # pylint: disable=unidiomatic-typecheck
        if survival_function.shape[1] > 1:
            raise ValueError(
                "Expecting a dataframe (or series) with a single column. Provide that or use utils.qth_survival_times."
            )

        survival_function = survival_function.T.squeeze()
    if cdf:
        if survival_function.iloc[0] > q:
            return -np.inf
        v = survival_function.index[survival_function.searchsorted([q])[0]]
    else:
        if survival_function.iloc[-1] > q:
            return np.inf
        v = survival_function.index[(-survival_function).searchsorted([-q])[0]]
    return v