Teradata Package for Python Function Reference | 17.10 - sort_index - Teradata Package for Python - Look here for syntax, methods and examples for the functions included in the Teradata Package for Python.

Teradata® Package for Python Function Reference

Product
Teradata Package for Python
Release Number
17.10
Published
April 2022
Language
English (United States)
Last Update
2022-08-19
lifecycle
previous
Product Category
Teradata Vantage
teradataml.geospatial.geodataframe.GeoDataFrame.sort_index = sort_index(self, axis=0, ascending=True, kind='quicksort')
DESCRIPTION:
    Gets sorted object by labels (along an axis) in either ascending or
    descending order for a teradataml GeoDataFrame.
        
PARAMETERS:
    axis:
        Optional Argument.
        Specifies the value to direct sorting on index or columns. 
        Values can be either 0 ('rows') OR 1 ('columns'), value as 0
        will sort on index (if no index is present then parent
        GeoDataFrame will be returned) and value as 1 will sort on
        columns names (if no index is present then parent GeoDataFrame
        will be returned with sorted columns) for the GeoDataFrame.
        Default value: 0
        Types: int
        
    ascending:
        Optional Argument.
        Specifies a flag to sort columns in either ascending (True)
        or descending (False).
        Default value: True
        Types: bool
    
    kind:
        Optional Argument.
        Specifies a desired algorithm to be used.
        Permitted values: 'quicksort', 'mergesort' or 'heapsort'
        Default value: 'quicksort'
        Types: str
 
RETURNS:
    teradataml GeoDataFrame
 
RAISES:
    TeradataMlException
 
EXAMPLES:
    >>> load_example_data("GeoDataFrame","sample_cities")
    >>> df = GeoDataFrame.from_table('sample_cities')
    >>> df
           city_name                                 city_shape
    skey
    1        Seaside  POLYGON ((10 10,10 20,20 20,20 15,10 10))
    0     Oceanville            POLYGON ((1 1,1 3,6 3,6 0,1 1))
    >>>
    >>> df.sort_index()
           city_name                                 city_shape
    skey
    0     Oceanville            POLYGON ((1 1,1 3,6 3,6 0,1 1))
    1        Seaside  POLYGON ((10 10,10 20,20 20,20 15,10 10))
    >>>
    >>> df.sort_index(0)
           city_name                                 city_shape
    skey
    0     Oceanville            POLYGON ((1 1,1 3,6 3,6 0,1 1))
    1        Seaside  POLYGON ((10 10,10 20,20 20,20 15,10 10))
    >>>
    >>> df.sort_index(1, False) # here 'False' means DESCENDING for respective axis
                                         city_shape   city_name
    skey
    1     POLYGON ((10 10,10 20,20 20,20 15,10 10))     Seaside
    0               POLYGON ((1 1,1 3,6 3,6 0,1 1))  Oceanville
    >>>
    >>> df.sort_index(1, True, 'mergesort')
           city_name                                 city_shape
    skey
    1        Seaside  POLYGON ((10 10,10 20,20 20,20 15,10 10))
    0     Oceanville            POLYGON ((1 1,1 3,6 3,6 0,1 1))
    >>>