Teradata Package for Python Function Reference on VantageCloud Lake | 17.20 - 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 on VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Package for Python
Release Number
17.20
Publication Date
November 2022
Content Type
Programming Reference
Publication ID
B700-4500-112K
ft:locale
en-US
ft:lastEdition
2024-02-21
ft:sourceId
FTML
dita:id
TeradataPython_FxRef_Lake_1720
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))
    >>>