title_wip

```
# Contains substring
ds['has_john'] = ds['name'].str.contains('John')

# Regex match
ds['valid_email'] = ds['email'].str.match(r'^[\w.-]+@[\w.-]+\.\w+$')
```

### Replace[​](#str-replace "Direct link to Replace")

|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Method ClickHouse Description|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `replace(pat, repl)` `replace()` Replace occurrences|  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `replace(pat, repl, regex=True)` `replaceRegexpAll()` Regex replace|  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `removeprefix(prefix)` - Remove prefix|  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | | `removesuffix(suffix)` - Remove suffix|  |  |  | | --- | --- | --- | | `translate(table)` - Translate characters | | | | | | | | | | | | | | | | | |

```
ds['cleaned'] = ds['text'].str.replace('\n', ' ')
ds['digits_only'] = ds['phone'].str.replace(r'\D', '', regex=True)
```

### Splitting[​](#str-split "Direct link to Splitting")

|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Method ClickHouse Description|  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `split(sep)` `splitByString()` Split into array|  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `rsplit(sep)` - Split from right|  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | | `partition(sep)` - Split into 3 parts|  |  |  | | --- | --- | --- | | `rpartition(sep)` - Split from right into 3 | | | | | | | | | | | | | | |

```
ds['parts'] = ds['path'].str.split('/')
```

### Padding[​](#str-padding "Direct link to Padding")

|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Method ClickHouse Description|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `pad(width)` `leftPad()` Left pad|  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `ljust(width)` `rightPad()` Right justify|  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `rjust(width)` `leftPad()` Left justify|  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | | `center(width)` - Center|  |  |  | | --- | --- | --- | | `zfill(width)` `leftPad(..., '0')` Zero fill | | | | | | | | | | | | | | | | | |

```
ds['padded_id'] = ds['id'].astype(str).str.zfill(6)
```

### Character Tests[​](#str-tests "Direct link to Character Tests")

|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Method Description|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `isalpha()` All alphabetic|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `isdigit()` All digits|  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `isalnum()` Alphanumeric|  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `isspace()` All whitespace|  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `isupper()` All uppercase|  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | | `islower()` All lowercase|  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | | `istitle()` Title case|  |  |  |  | | --- | --- | --- | --- | | `isnumeric()` Numeric characters|  |  | | --- | --- | | `isdecimal()` Decimal characters | | | | | | | | | | | | | | | | | | | |

```
ds['is_numeric'] = ds['code'].str.isdigit()
```

### Other[​](#str-other "Direct link to Other")

|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Method Description|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `repeat(n)` Repeat n times|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `reverse()` Reverse string|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `wrap(width)` Wrap text|  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `encode(enc)` Encode|  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `decode(enc)` Decode|  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `normalize(form)` Unicode normalize|  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | | `extract(pat)` Extract regex groups|  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | | `extractall(pat)` Extract all matches|  |  |  |  | | --- | --- | --- | --- | | `cat(sep)` Concatenate all|  |  | | --- | --- | | `get_dummies(sep)` Dummy variables | | | | | | | | | | | | | | | | | | | | | |

---

## DateTime Accessor (`.dt`)[​](#dt "Direct link to dt")

All 42+ pandas `.dt` methods plus ClickHouse datetime functions.

### Date Components[​](#dt-components "Direct link to Date Components")