Teradata Package for Python Function Reference - dropna - 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.00
Published
November 2021
Language
English (United States)
Last Update
2021-11-19
lifecycle
previous
Product Category
Teradata Vantage
teradataml.dataframe.dataframe.DataFrame.dropna = dropna(self, how='any', thresh=None, subset=None)
DESCRIPTION:
    Removes rows with null values.
 
PARAMETERS:
    how:
        Optional Argument.
        Specifies how rows are removed.
        'any' removes rows with at least one null value.
        'all' removes rows with all null values.
        Default Value: 'any'
        Permitted Values: 'any' or 'all'
        Types: str
 
    thresh:
        Optional Argument.
        Specifies the minimum number of non null values in a row to include.
        Types: int
 
    subset:
        Optional Argument.
        Specifies list of column names to include, in array-like format.
        Types: str OR list of Strings (str)
 
RETURNS:
    teradataml DataFrame
 
RAISE:
    TeradataMlException
 
EXAMPLES:
    >>> load_example_data("dataframe","sales")
    >>> df = DataFrame('sales')
    >>> df
                  Feb   Jan   Mar   Apr    datetime
    accounts
    Jones LLC   200.0   150   140   180  04/01/2017
    Yellow Inc   90.0  None  None  None  04/01/2017
    Orange Inc  210.0  None  None   250  04/01/2017
    Blue Inc     90.0    50    95   101  04/01/2017
    Alpha Co    210.0   200   215   250  04/01/2017
    Red Inc     200.0   150   140  None  04/01/2017
 
    # Drop the rows where at least one element is null.
    >>> df.dropna()
                 Feb  Jan  Mar  Apr    datetime
    accounts
    Blue Inc    90.0   50   95  101  04/01/2017
    Jones LLC  200.0  150  140  180  04/01/2017
    Alpha Co   210.0  200  215  250  04/01/2017
 
    # Drop the rows where all elements are nulls for columns 'Jan' and 'Mar'.
    >>> df.dropna(how='all', subset=['Jan','Mar'])
                 Feb  Jan  Mar   Apr    datetime
    accounts
    Alpha Co   210.0  200  215   250  04/01/2017
    Jones LLC  200.0  150  140   180  04/01/2017
    Red Inc    200.0  150  140  None  04/01/2017
    Blue Inc    90.0   50   95   101  04/01/2017
 
    # Keep only the rows with at least 4 non null values.
    >>> df.dropna(thresh=4)
                  Feb   Jan   Mar   Apr    datetime
    accounts
    Jones LLC   200.0   150   140   180  04/01/2017
    Blue Inc     90.0    50    95   101  04/01/2017
    Orange Inc  210.0  None  None   250  04/01/2017
    Alpha Co    210.0   200   215   250  04/01/2017
    Red Inc     200.0   150   140  None  04/01/2017
 
    # Keep only the rows with at least 5 non null values.
    >>> df.dropna(thresh=5)
                 Feb  Jan  Mar   Apr    datetime
    accounts
    Alpha Co   210.0  200  215   250  04/01/2017
    Jones LLC  200.0  150  140   180  04/01/2017
    Blue Inc    90.0   50   95   101  04/01/2017
    Red Inc    200.0  150  140  None  04/01/2017