Splits an SArray of datetime type to multiple columns, return a
        new SFrame that contains expanded columns. A SArray of datetime will be
        split by default into an SFrame of 6 columns, one for each
        year/month/day/hour/minute/second element.

        **Column Naming**

        When splitting a SArray of datetime type, new columns are named:
        prefix.year, prefix.month, etc. The prefix is set by the parameter
        "column_name_prefix" and defaults to 'X'. If column_name_prefix is
        None or empty, then no prefix is used.

        **Timezone Column**
        If timezone parameter is True, then timezone information is represented
        as one additional column which is a float shows the offset from
        GMT(0.0) or from UTC.


        Parameters
        ----------
        column_name_prefix: str, optional
            If provided, expanded column names would start with the given prefix.
            Defaults to "X".

        limit: list[str], optional
            Limits the set of datetime elements to expand.
            Possible values are 'year','month','day','hour','minute','second',
            'weekday', 'isoweekday', 'tmweekday', and 'us'.
            If not provided, only ['year','month','day','hour','minute','second']
            are expanded.

            - 'year': The year number
            - 'month': A value between 1 and 12 where 1 is January.
            - 'day': Day of the months. Begins at 1.
            - 'hour': Hours since midnight.
            - 'minute': Minutes after the hour.
            - 'second': Seconds after the minute.
            - 'us': Microseconds after the second. Between 0 and 999,999.
            - 'weekday': A value between 0 and 6 where 0 is Monday.
            - 'isoweekday': A value between 1 and 7 where 1 is Monday.
            - 'tmweekday': A value between 0 and 7 where 0 is Sunday

        timezone: bool, optional
            A boolean parameter that determines whether to show timezone column or not.
            Defaults to False.

        Returns
        -------
        out : SFrame
            A new SFrame that contains all expanded columns

        Examples
        --------
        To expand only day and year elements of a datetime SArray

         >>> sa = SArray(
            [datetime(2011, 1, 21, 7, 7, 21, tzinfo=GMT(0)),
             datetime(2010, 2, 5, 7, 8, 21, tzinfo=GMT(4.5)])

         >>> sa.split_datetime(column_name_prefix=None,limit=['day','year'])
            Columns:
                day   int
                year  int
            Rows: 2
            Data:
            +-------+--------+
            |  day  |  year  |
            +-------+--------+
            |   21  |  2011  |
            |   5   |  2010  |
            +-------+--------+
            [2 rows x 2 columns]


        To expand only year and timezone elements of a datetime SArray
        with timezone column represented as a string. Columns are named with prefix:
        'Y.column_name'.

        >>> sa.split_datetime(column_name_prefix="Y",limit=['year'],timezone=True)
            Columns:
                Y.year  int
                Y.timezone float
            Rows: 2
            Data:
            +----------+---------+
            |  Y.year  | Y.timezone |
            +----------+---------+
            |    2011  |  0.0    |
            |    2010  |  4.5    |
            +----------+---------+
            [2 rows x 2 columns]

def split_datetime(self, column_name_prefix = "X", limit=None, timezone=False):
        """
        Splits an SArray of datetime type to multiple columns, return a
        new SFrame that contains expanded columns. A SArray of datetime will be
        split by default into an SFrame of 6 columns, one for each
        year/month/day/hour/minute/second element.

        **Column Naming**

        When splitting a SArray of datetime type, new columns are named:
        prefix.year, prefix.month, etc. The prefix is set by the parameter
        "column_name_prefix" and defaults to 'X'. If column_name_prefix is
        None or empty, then no prefix is used.

        **Timezone Column**
        If timezone parameter is True, then timezone information is represented
        as one additional column which is a float shows the offset from
        GMT(0.0) or from UTC.


        Parameters
        ----------
        column_name_prefix: str, optional
            If provided, expanded column names would start with the given prefix.
            Defaults to "X".

        limit: list[str], optional
            Limits the set of datetime elements to expand.
            Possible values are 'year','month','day','hour','minute','second',
            'weekday', 'isoweekday', 'tmweekday', and 'us'.
            If not provided, only ['year','month','day','hour','minute','second']
            are expanded.

            - 'year': The year number
            - 'month': A value between 1 and 12 where 1 is January.
            - 'day': Day of the months. Begins at 1.
            - 'hour': Hours since midnight.
            - 'minute': Minutes after the hour.
            - 'second': Seconds after the minute.
            - 'us': Microseconds after the second. Between 0 and 999,999.
            - 'weekday': A value between 0 and 6 where 0 is Monday.
            - 'isoweekday': A value between 1 and 7 where 1 is Monday.
            - 'tmweekday': A value between 0 and 7 where 0 is Sunday

        timezone: bool, optional
            A boolean parameter that determines whether to show timezone column or not.
            Defaults to False.

        Returns
        -------
        out : SFrame
            A new SFrame that contains all expanded columns

        Examples
        --------
        To expand only day and year elements of a datetime SArray

         >>> sa = SArray(
            [datetime(2011, 1, 21, 7, 7, 21, tzinfo=GMT(0)),
             datetime(2010, 2, 5, 7, 8, 21, tzinfo=GMT(4.5)])

         >>> sa.split_datetime(column_name_prefix=None,limit=['day','year'])
            Columns:
                day   int
                year  int
            Rows: 2
            Data:
            +-------+--------+
            |  day  |  year  |
            +-------+--------+
            |   21  |  2011  |
            |   5   |  2010  |
            +-------+--------+
            [2 rows x 2 columns]


        To expand only year and timezone elements of a datetime SArray
        with timezone column represented as a string. Columns are named with prefix:
        'Y.column_name'.

        >>> sa.split_datetime(column_name_prefix="Y",limit=['year'],timezone=True)
            Columns:
                Y.year  int
                Y.timezone float
            Rows: 2
            Data:
            +----------+---------+
            |  Y.year  | Y.timezone |
            +----------+---------+
            |    2011  |  0.0    |
            |    2010  |  4.5    |
            +----------+---------+
            [2 rows x 2 columns]
        """
        from .sframe import SFrame as _SFrame

        if self.dtype != datetime.datetime:
            raise TypeError("Only column of datetime type is supported.")

        if column_name_prefix is None:
            column_name_prefix = ""
        if six.PY2 and type(column_name_prefix) == unicode:
            column_name_prefix = column_name_prefix.encode('utf-8')
        if type(column_name_prefix) != str:
            raise TypeError("'column_name_prefix' must be a string")

        # convert limit to column_keys
        if limit is not None:
            if not _is_non_string_iterable(limit):
                raise TypeError("'limit' must be a list")

            name_types = set([type(i) for i in limit])
            if (len(name_types) != 1):
                raise TypeError("'limit' contains values that are different types")

            if (name_types.pop() != str):
                raise TypeError("'limit' must contain string values.")

            if len(set(limit)) != len(limit):
                raise ValueError("'limit' contains duplicate values")

        column_types = []

        if(limit is None):
            limit = ['year','month','day','hour','minute','second']

        column_types = [int] * len(limit)

        if(timezone == True):
            limit += ['timezone']
            column_types += [float]


        with cython_context():
           return _SFrame(_proxy=self.__proxy__.expand(column_name_prefix, limit, column_types))