<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def akinesia_times(self, data_frame):
 """ This method calculates akinesia times, mean dwell time on each key in milliseconds :param data_frame: the data frame :type data_frame: pandas.DataFrame :return at: akinesia times :rtype at: float :return duration: test duration (seconds) :rtype duration: float """


        raise_timestamps = data_frame.td[data_frame.action_type == 1]
        down_timestamps = data_frame.td[data_frame.action_type == 0]
        if len(raise_timestamps) == len(down_timestamps):
            at = np.mean(down_timestamps.values - raise_timestamps.values)
        else:
            if len(raise_timestamps) > len(down_timestamps):
                at = np.mean(down_timestamps.values - raise_timestamps.values[:-(len(raise_timestamps)
                                                                                 - len(down_timestamps))])
            else:
                at = np.mean(down_timestamps.values[:-(len(down_timestamps)-len(raise_timestamps))]
                             - raise_timestamps.values)
        duration = math.ceil(data_frame.td[-1])
        return np.abs(at), duration