strip() Method | Teradata Package for Python - strip() Method - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

Use the strip() method to remove leading and trailing whitespace from string values in a column.

Example Setup

>>> df = DataFrame('employee_info')
>>> df
            first_name marks   dob joined_date
employee_no                                  
101              abcde  None  None    02/12/05
112               None  None  None    18/12/05
100               abcd  None  None        None
>>> fn = df.first_name
# create a column with some whitespace
>>> wdf = df.assign(drop_columns = True, fn = fn, w_spaces = '\n ' + fn + '\v\f \t')

Example 1: Display without the Strip Method

>>> >>> wdf
      fn       w_spaces
0   None           None
1  abcde  \n abcde
 
                   \t
2   abcd   \n abcd
 
                   \t

Example 2: Display with the Strip Method

>>> wdf.assign(drop_columns = True, wo_wspaces = wdf.w_spaces.str.strip())
  wo_wspaces
0       None
1      abcde
2       abcd