strip() Method - Teradata Python Package

Teradata® Python Package User Guide

Product
Teradata Python Package
Release Number
16.20
Published
February 2020
Language
English (United States)
Last Update
2020-02-29
dita:mapPath
rkb1531260709148.ditamap
dita:ditavalPath
Generic_no_ie_no_tempfilter.ditaval
dita:id
B700-4006
lifecycle
previous
Product Category
Teradata Vantage

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