MCPcopy
hub / github.com/pandas-dev/pandas / _remove_whitespace

Function _remove_whitespace

pandas/io/html.py:69–85  ·  view source on GitHub ↗

Replace extra whitespace inside of a string with a single space. Parameters ---------- s : str or unicode The string from which to remove extra whitespace. regex : re.Pattern The regular expression to use to remove extra whitespace. Returns -------

(s: str, regex: Pattern = _RE_WHITESPACE)

Source from the content-addressed store, hash-verified

67
68
69def _remove_whitespace(s: str, regex: Pattern = _RE_WHITESPACE) -> str:
70 """
71 Replace extra whitespace inside of a string with a single space.
72
73 Parameters
74 ----------
75 s : str or unicode
76 The string from which to remove extra whitespace.
77 regex : re.Pattern
78 The regular expression to use to remove extra whitespace.
79
80 Returns
81 -------
82 subd : str or unicode
83 `s` with all extra whitespace replaced with a single space.
84 """
85 return regex.sub(" ", s.strip())
86
87
88def _get_skiprows(skiprows: int | Sequence[int] | slice | None) -> int | Sequence[int]:

Callers 2

try_remove_wsMethod · 0.90

Calls 2

stripMethod · 0.80
subMethod · 0.45

Tested by 1

try_remove_wsMethod · 0.72