Teradata Package for Python Function Reference on VantageCloud Lake | 17.20 - strip - 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.dataframe.sql.DataFrameColumn.strip = strip(self)
       Remove leading and trailing whitespace.
       REFERENCE:
           SQL Functions, Operators, Expressions, and Predicates
           Chapter 26 String Operators and Functions
 
       PARAMETERS:
           None
 
       RETURNS:
           A str Series with leading and trailing whitespace removed
 
       EXAMPLES:
           >>> load_example_data("dataframe", "sales")
           >>> df = DataFrame("sales")
           >>> df
                         Feb    Jan    Mar    Apr    datetime
           accounts
           Orange Inc  210.0    NaN    NaN  250.0  04/01/2017
           Blue Inc     90.0   50.0   95.0  101.0  04/01/2017
           Yellow Inc   90.0    NaN    NaN    NaN  04/01/2017
           Red Inc     200.0  150.0  140.0    NaN  04/01/2017
           Jones LLC   200.0  150.0  140.0  180.0  04/01/2017
           Alpha Co    210.0  200.0  215.0  250.0  04/01/2017
 
           >>> accounts = df['accounts']
 
           # create a column with some whitespace
           >>> wdf = df.assign(drop_columns = True,
                             accounts = accounts,
                             w_spaces = '
' + accounts + '     ')
           >>> wdf
 
                                 w_spaces
           accounts
           Blue Inc      
Blue Inc
 
               
           Orange Inc  
Orange Inc
 
               
           Red Inc        
Red Inc
 
               
           Yellow Inc  
Yellow Inc
 
               
           Jones LLC    
Jones LLC
 
               
           Alpha Co      
Alpha Co
 
               
 
           # Example 1: Strip the leading and trailing whitespace.
           >>> wdf.assign(drop_columns = True,
                        wo_wspaces = wdf.w_spaces.str.strip())
 
              wo_wspaces
           0    Blue Inc
           1  Orange Inc
           2     Red Inc
           3  Yellow Inc
           4   Jones LLC
           5    Alpha Co