October 2019
Beginner to intermediate
674 pages
16h 43m
English
The strip() function can come in quite handy in data cleaning. It removes trailing whitespaces or any specific pattern of a string from textual content in series. If the substring to be removed is not specified, trailing whitespaces are trimmed by default. The following example demonstrates an application of the strip function with stray whitespaces:
strip_series = pd.Series(["\tChina", "U.S.A ", "U\nK"])strip_series
The following is the output:

The following example demonstrates an application of the strip() function with trailing whitespaces:
strip_series.strip()
The following is the output: ...
Read now
Unlock full access