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
)
| 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 |