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

Teradata® Package for Python User Guide

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for Python
Release Number
20.00
Published
December 2024
ft:locale
en-US
ft:lastEdition
2025-01-23
dita:mapPath
nvi1706202040305.ditamap
dita:ditavalPath
plt1683835213376.ditaval
dita:id
rkb1531260709148
lifecycle
latest
Product Category
Teradata Vantage

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