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

Teradata® Python Package Function Reference

Product
Teradata Python Package
Release Number
16.20
Published
February 2020
Language
English (United States)
Last Update
2020-07-17
lifecycle
previous
Product Category
Teradata Vantage
teradataml.dataframe.dataframe.DataFrame.drop = drop(self, labels=None, axis=0, columns=None)
DESCRIPTION:
    Drop specified labels from rows or columns.
 
    Remove rows or columns by specifying label names and corresponding
    axis, or by specifying the index or column names directly.
 
PARAMETERS:
    labels:
        Optional Argument. Required when columns is not provided.
        Single label or list-like. Can be Index or column labels to drop depending on axis.
        Types: str OR list of Strings (str)
 
    axis:
        Optional Argument.
        0 or 'index' for index labels
        1 or 'columns' for column labels
        Default Values: 0
        Permitted Values: 0, 1, 'index', 'columns'
        Types: int OR str
 
    columns:
        Optional Argument. Required when labels is not provided.
        Single label or list-like. This is an alternative to specifying axis=1 with labels.
        Cannot specify both labels and columns.
        Types: str OR list of Strings (str)
 
RETURNS:
    teradataml DataFrame
 
RAISE:
    TeradataMlException
 
EXAMPLES:
    >>> load_example_data("dataframe","admissions_train")
    >>> df = DataFrame('admissions_train')
    >>> df
       masters   gpa     stats programming admitted
    id
    5       no  3.44    Novice      Novice        0
    7      yes  2.33    Novice      Novice        1
    22     yes  3.46    Novice    Beginner        0
    17      no  3.83  Advanced    Advanced        1
    13      no  4.00  Advanced      Novice        1
    19     yes  1.98  Advanced    Advanced        0
    36      no  3.00  Advanced      Novice        0
    15     yes  4.00  Advanced    Advanced        1
    34     yes  3.85  Advanced    Beginner        0
    40     yes  3.95    Novice    Beginner        0
 
    # Drop columns
    >>> df.drop(['stats', 'admitted'], axis=1)
       programming masters   gpa
    id
    5       Novice      no  3.44
    34    Beginner     yes  3.85
    13      Novice      no  4.00
    40    Beginner     yes  3.95
    22    Beginner     yes  3.46
    19    Advanced     yes  1.98
    36      Novice      no  3.00
    15    Advanced     yes  4.00
    7       Novice     yes  2.33
    17    Advanced      no  3.83
 
    >>> df.drop(columns=['stats', 'admitted'])
       programming masters   gpa
    id
    5       Novice      no  3.44
    34    Beginner     yes  3.85
    13      Novice      no  4.00
    19    Advanced     yes  1.98
    15    Advanced     yes  4.00
    40    Beginner     yes  3.95
    7       Novice     yes  2.33
    22    Beginner     yes  3.46
    36      Novice      no  3.00
    17    Advanced      no  3.83
 
    # Drop a row by index
    >>> df1 = df[df.gpa == 4.00]
    >>> df1
       masters  gpa     stats programming admitted
    id
    13      no  4.0  Advanced      Novice        1
    29     yes  4.0    Novice    Beginner        0
    15     yes  4.0  Advanced    Advanced        1
    >>> df1.drop([13,15], axis=0)
       masters  gpa   stats programming admitted
    id
    29     yes  4.0  Novice    Beginner        0
    >>>