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

Teradata® Package for Python User Guide

Product
Teradata Package for Python
Release Number
17.00
Published
November 2021
Language
English (United States)
Last Update
2022-01-14
dita:mapPath
bol1585763678431.ditamap
dita:ditavalPath
ayr1485454803741.ditaval
dita:id
rkb1531260709148

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

Example Prerequisite

>>> 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: Display without the Strip Method

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

Example: 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