MCPcopy
hub / github.com/pathwaycom/pathway / strip

Method strip

python/pathway/internals/expressions/string.py:396–437  ·  view source on GitHub ↗

Returns a copy of the string with specified leading and trailing characters removed. If no arguments are passed, remove the leading and trailing whitespaces. Example: >>> import pathway as pw >>> table = pw.debug.table_from_markdown( ... ''' ...

(
        self, chars: expr.ColumnExpression | str | None = None
    )

Source from the content-addressed store, hash-verified

394 )
395
396 def strip(
397 self, chars: expr.ColumnExpression | str | None = None
398 ) -> expr.ColumnExpression:
399 """Returns a copy of the string with specified leading and trailing characters
400 removed. If no arguments are passed, remove the leading and trailing whitespaces.
401
402
403 Example:
404
405 >>> import pathway as pw
406 >>> table = pw.debug.table_from_markdown(
407 ... '''
408 ... | name
409 ... 1 | Alice
410 ... 2 | Bob
411 ... 3 | CAROLE
412 ... 4 | david
413 ... '''
414 ... )
415 >>> table += table.select(name_strip=table.name.str.strip("Aod"))
416 >>> pw.debug.compute_and_print(table, include_id=False)
417 name | name_strip
418 Alice | lice
419 Bob | Bob
420 CAROLE | CAROLE
421 david | avi
422 """
423
424 return expr.MethodCallExpression(
425 (
426 (
427 (dt.STR, dt.Optional(dt.STR)),
428 dt.STR,
429 lambda x, y: api.Expression.apply(
430 str.strip, x, y, dtype=dt.STR.to_engine()
431 ),
432 ),
433 ),
434 "str.strip",
435 self._expression,
436 chars,
437 )
438
439 def title(self) -> expr.ColumnExpression:
440 """Returns a copy of the string where where words start with an uppercase character

Callers 15

parse_cited_responseFunction · 0.80
on_changeMethod · 0.80
_markdown_to_pandasFunction · 0.80
read_jsonlinesFunction · 0.80
test_compute_and_printFunction · 0.80
test_stripFunction · 0.80
__init__Method · 0.80
_runMethod · 0.80
check_output_correctnessFunction · 0.80

Calls 2

applyMethod · 0.80
to_engineMethod · 0.45