strip() Method

Teradata® Python Package User Guide

brand
Teradata Vantage
prodname
Teradata Python Package
vrm_release
16.20
category
User Guide
featnum
B700-4006-098K

The strip() method is similar to the strip method of strings in Python. It removes leading and trailing whitespace from string values in a column.

Example Prerequisite

>>> tdf = DataFrame('iris')
>>> species = tdf['Name']
# create a column with some whitespace
>>> wdf = df.assign(drop_columns = True,
                     species = species,
                     w_spaces = '\n ' + species + '\v\f \t')

Example: Display without the Strip Method

>>> wdf.head(5)
 
             species           w_spaces
  0 Iris-versicolor \n Iris-versicolor
  
  \t
  1 Iris-versicolor \n Iris-versicolor
  
  \t
  2 Iris-virginica \n Iris-virginica
  
  \t
  3 Iris-versicolor \n Iris-versicolor
  
  \t
  4 Iris-virginica \n Iris-virginica
  
  \t

Example: Display with the Strip Method

>>> wdf.assign(drop_columns = True,
               wo_wspaces = wdf.w_spaces.str.strip()).head(5)
  
         wo_wspaces
  
  0 Iris-versicolor
  1 Iris-versicolor
  2 Iris-virginica
  3 Iris-versicolor
  4 Iris-virginica