shape: (3, 1)
| Password |
|---|
| str |
| "marm1te" |
| "jam543" |
| "p3anutButt3r" |
count_matches
Joram Mutenge
2025-12-21
You have a table of passwords and, for some reason, you want to count the number of digits in each password. This is possible using Polars. Below is a dataframe of passwords.
| Password |
|---|
| str |
| "marm1te" |
| "jam543" |
| "p3anutButt3r" |
You can count the number of digits in each password using the function count_matches like this:
| Password | Num_of_Digits |
|---|---|
| str | u32 |
| "marm1te" | 1 |
| "jam543" | 3 |
| "p3anutButt3r" | 2 |
Discover even more ways to use Polars in my Polars course.