<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def transform_data(self, data):
        '''Transform Pandas Timeseries into JSON format

        Parameters
        ----------
        data: DataFrame or Series
            Pandas DataFrame or Series must have datetime index

        Returns
        -------
        JSON to object.json_data

        Example
        -------
        >>>vis.transform_data(df)
        >>>vis.json_data

        '''

        def type_check(value):
            '''Type check values for JSON serialization. Native Python JSON
            serialization will not recognize some Numpy data types properly,
            so they must be explictly converted.'''
            if pd.isnull(value):
                return None
            elif (isinstance(value, pd.tslib.Timestamp) or
                  isinstance(value, pd.Period)):
                return time.mktime(value.timetuple())
            elif isinstance(value, (int, np.integer)):
                return int(value)
            elif isinstance(value, (float, np.float_)):
                return float(value)
            elif isinstance(value, str):
                return str(value)
            else:
                return value

        objectify = lambda dat: [{"x": type_check(x), "y": type_check(y)}
                                 for x, y in dat.iteritems()]

        self.raw_data = data
        if isinstance(data, pd.Series):
            data.name = data.name or 'data'
            self.json_data = [{'name': data.name, 'data': objectify(data)}]
        elif isinstance(data, pd.DataFrame):
            self.json_data = [{'name': x[0], 'data': objectify(x[1])}
                              for x in data.iteritems()]