String Functions Expr
Extension for String Manipulation and Metrics
String-related utils, including edit distances, simple cleaning, etc.
Functions:
| Name | Description |
|---|---|
extract_numbers |
Extracts numbers from the string column, and stores them in a list. |
filter_by_hamming |
Returns whether the hamming distance between self and other is <= bound. This is |
filter_by_levenshtein |
Returns whether the Levenshtein distance between self and other is <= bound. This is |
map_words |
Replace words based on the specified mapping. |
normalize_whitespace |
|
remove_diacritics |
Remove diacritics (e.g. è -> e) by converting the string to its NFD normalized |
replace_non_ascii |
Replaces non-Ascii values with the specified value. |
similar_to_vocab |
Compare each word in the vocab with each word in the column c. Returns a boolean |
str_d_leven |
Computes the Damerau-Levenshtein distance between this and the other str. |
str_fuzz |
Calculates the normalized Indel similarity. (See the package rapidfuzz, fuzz.ratio for more |
str_hamming |
Computes the hamming distance between two strings. If they do not have the same length, null will |
str_jaccard |
Treats substrings of size |
str_jaro |
Computes the Jaro similarity between this and the other str. Jaro distance = 1 - Jaro sim. |
str_jw |
Computes the Jaro-Winkler similarity between this and the other str. |
str_lcs_subseq |
Extracts the longest common subsequence from the string between this and the other string. |
str_lcs_subseq_dist |
Computes the Longest Common Subsequence distance/similarity between this and the other str. |
str_lcs_substr |
Extracts the longest common substring from the string between this and the other string. |
str_leven |
Computes the Levenshtein distance between this and the other str. |
str_nearest |
Finds the string in the column that is nearest to the given word in the given metric. This algorithm is |
str_osa |
Computes the Optimal String Alignment distance between this and the other str. |
str_sorensen_dice |
Treats substrings of size |
str_tversky_sim |
Treats substrings of size |
to_camel_case |
Turns itself into camel case. E.g. helloWorld |
to_constant_case |
Turns itself into constant case. E.g. Hello_World |
to_pascal_case |
Turns itself into Pascal case. E.g. HelloWorld |
to_snake_case |
Turns itself into snake case. E.g. hello_world |
extract_numbers(c, ignore_comma=False, join_by='', dtype=pl.String)
Extracts numbers from the string column, and stores them in a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
str | Expr
|
The string column |
required |
ignore_comma
|
bool
|
Whether to remove all comma before matching for numbers |
False
|
join_by
|
str
|
If dtype is pl.String, join the list of strings using the value given here |
''
|
dtype
|
DataType
|
The desired inner dtype for the extracted data. Should either be one of one of Polars' numerical types or pl.String |
String
|
Examples:
>>> df = pl.DataFrame(
... {
... "survey": [
... "0% of my time",
... "1% to 25% of my time",
... "75% to 99% of my time",
... "50% to 74% of my time",
... "75% to 99% of my time",
... "50% to 74% of my time",
... ]
... }
... )
>>> df.select(pl.col("survey").str_ext.extract_numbers(dtype=pl.UInt32))
shape: (6, 1)
┌───────────┐
│ survey │
│ --- │
│ list[u32] │
╞═══════════╡
│ [0] │
│ [1, 25] │
│ [75, 99] │
│ [50, 74] │
│ [75, 99] │
│ [50, 74] │
└───────────┘
>>> df.select(pl.col("survey").str_ext.extract_numbers(join_by="-", dtype=pl.String))
shape: (6, 1)
┌────────┐
│ survey │
│ --- │
│ str │
╞════════╡
│ 0 │
│ 1-25 │
│ 75-99 │
│ 50-74 │
│ 75-99 │
│ 50-74 │
└────────┘
Source code in python/polars_ds/exprs/string.py
762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 | |
filter_by_hamming(c, other, bound, pad=False, parallel=False)
Returns whether the hamming distance between self and other is <= bound. This is faster than computing hamming distance and then doing a filter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
str | Expr
|
Either the name of the column or a Polars expression |
required |
other
|
str | Expr
|
Either the name of the column or a Polars expression. If you want to compare a single string with all of column c, use pl.lit(your_str) |
required |
bound
|
int
|
Closed upper bound. If distance <= bound, return true and false otherwise. |
required |
pad
|
bool
|
Whether to pad the strings to the same length. If False, and strings have different lengths, they will be filtered out. |
False
|
parallel
|
bool
|
Whether to run it in parallel. Note that this is only recommended when this query is the only one in execution and when this is not executed in any aggregation / streaming context. |
False
|
Source code in python/polars_ds/exprs/string.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
filter_by_levenshtein(c, other, bound, parallel=False, as_bytes=False)
Returns whether the Levenshtein distance between self and other is <= bound. This is faster than computing levenshtein distance and then doing a filter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
str | Expr
|
Either the name of the column or a Polars expression |
required |
other
|
str | Expr
|
Either the name of the column or a Polars expression. If you want to compare a single string with all of column c, use pl.lit(your_str) |
required |
bound
|
int
|
Closed upper bound. If distance <= bound, return true and false otherwise. |
required |
parallel
|
bool
|
Whether to run it in parallel. Note that this is only recommended when this query is the only one in execution and when this is not executed in any aggregation / streaming context. |
False
|
as_bytes
|
bool
|
Whether to treat the strings as ASCII characters. This will boost performance but does not work on non-ASCII characters. |
False
|
Source code in python/polars_ds/exprs/string.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
map_words(c, mapping)
Replace words based on the specified mapping.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
str | Expr
|
The string column |
required |
mapping
|
dict[str, str]
|
A dictionary of {word: the replacement} |
required |
Returns:
| Type | Description |
|---|---|
Expr
|
|
Examples:
>>> df = pl.DataFrame({"x": ["one two three"]})
>>> df.select(pds.map_words("x", {"two": "2"}))
shape: (1, 1)
┌─────────────┐
│ x │
│ --- │
│ str │
╞═════════════╡
│ one 2 three │
└─────────────┘
Source code in python/polars_ds/exprs/string.py
927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 | |
normalize_whitespace(c, only_spaces=False)
Normalize whitespace to one, e.g. 'a b' -> 'a b'.
Parameters
Parameters
c : str | pl.Expr
The string column
only_spaces: bool
If True, only split on the space character ' ' instead of any whitespace
character such as ' ' and '
', by default False
Returns
Returns
pl.Expr
Examples
Examples
shape: (2, 3)
┌─────────┬─────┬────────┐
│ x ┆ y ┆ z │
│ --- ┆ --- ┆ --- │
│ str ┆ str ┆ str │
╞═════════╪═════╪════════╡
│ a b ┆ a b ┆ a b │
│ a b ┆ a b ┆ a b│
└─────────┴─────┴────────┘
Source code in python/polars_ds/exprs/string.py
963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 | |
remove_diacritics(c)
Remove diacritics (e.g. è -> e) by converting the string to its NFD normalized form and removing the resulting non-ASCII components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
str | Expr
|
|
required |
Returns:
| Type | Description |
|---|---|
Expr
|
|
Examples:
>>> df = pl.DataFrame({"x": ["mercy", "mèrcy"]})
>>> df.select(pds.replace_non_ascii("x"))
shape: (2, 1)
┌───────┐
│ x │
│ --- │
│ str │
╞═══════╡
│ mercy │
│ mercy │
└───────┘
Source code in python/polars_ds/exprs/string.py
894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 | |
replace_non_ascii(c, value='')
Replaces non-Ascii values with the specified value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
str | Expr
|
The column name or expression |
required |
value
|
str
|
The value to replace non-Ascii values with, by default "" |
''
|
Returns:
| Type | Description |
|---|---|
Expr
|
|
Examples:
>>> df = pl.DataFrame({"x": ["mercy", "xbĤ", "ĤŇƏ"]})
>>> df.select(pds.replace_non_ascii("x"))
shape: (3, 1)
┌───────┐
│ x │
│ --- │
│ str │
╞═══════╡
│ mercy │
│ xb │
│ │
└───────┘
Source code in python/polars_ds/exprs/string.py
853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 | |
similar_to_vocab(c, vocab, threshold, metric='lv', strategy='avg', as_bytes=False)
Compare each word in the vocab with each word in the column c. Returns a boolean that indicates whether there exist words in c that are similar to words in vocab.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
str | Expr
|
The string column |
required |
vocab
|
List[str]
|
Any iterable collection of strings |
required |
threshold
|
float
|
A entry is considered similar to the words in the vocabulary if the similarity is above (>=) the threshold |
required |
metric
|
Literal['lv', 'dlv', 'jw', 'osa']
|
Which similarity metric to use. One of |
'lv'
|
strategy
|
Literal['avg', 'all', 'any']
|
If |
'avg'
|
as_bytes
|
bool
|
Only works for Levenshtein distance. Whether to treat the strings as ASCII characters. This will boost performance but does not work on non-ASCII characters. |
False
|
Source code in python/polars_ds/exprs/string.py
702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 | |
str_d_leven(c, other, parallel=False, return_sim=False, as_bytes=False)
Computes the Damerau-Levenshtein distance between this and the other str.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
str | Expr
|
The string column |
required |
other
|
str | Expr
|
Either the name of the column or a Polars expression. If you want to compare a single string with all of column c, use pl.lit(your_str) |
required |
parallel
|
bool
|
Whether to run it in parallel. Note that this is only recommended when this query is the only one in execution and when this is not executed in any aggregation / streaming context. |
False
|
return_sim
|
bool
|
If true, return normalized Damerau-Levenshtein. |
False
|
as_bytes
|
bool
|
Whether to treat the strings as ASCII characters. This will boost performance but does not work on non-ASCII characters. |
False
|
Source code in python/polars_ds/exprs/string.py
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 | |
str_fuzz(c, other, parallel=False)
Calculates the normalized Indel similarity. (See the package rapidfuzz, fuzz.ratio for more information.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
str | Expr
|
The string column |
required |
other
|
str | Expr
|
Either the name of the column or a Polars expression. If you want to compare a single string with all of column c, use pl.lit(your_str) |
required |
parallel
|
bool
|
Whether to run it in parallel. Note that this is only recommended when this query is the only one in execution and when this is not executed in any aggregation / streaming context. |
False
|
Source code in python/polars_ds/exprs/string.py
679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 | |
str_hamming(c, other, pad=False, parallel=False)
Computes the hamming distance between two strings. If they do not have the same length, null will be returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
str | Expr
|
Either the name of the column or a Polars expression |
required |
other
|
str | Expr
|
Either the name of the column or a Polars expression. If you want to compare a single string with all of column c, use pl.lit(your_str) |
required |
pad
|
bool
|
Whether to pad the string when lengths are not equal. |
False
|
parallel
|
bool
|
Whether to run it in parallel. Note that this is only recommended when this query is the only one in execution and when this is not executed in any aggregation / streaming context. |
False
|
Source code in python/polars_ds/exprs/string.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
str_jaccard(c, other, substr_size=2, parallel=False)
Treats substrings of size substr_size as a set. And computes the jaccard similarity between
this word and the other.
Note this treats substrings at the byte level under the hood, not at the char level. So non-ASCII characters may have problems.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
str | Expr
|
The string column |
required |
other
|
str | Expr
|
Either the name of the column or a Polars expression. If you want to compare a single string with all of column c, use pl.lit(your_str) |
required |
substr_size
|
int
|
The substring size for Jaccard similarity. E.g. if substr_size = 2, "apple" will be decomposed into the set ('ap', 'pp', 'pl', 'le') before being compared. |
2
|
parallel
|
bool
|
Whether to run it in parallel. Note that this is only recommended when this query is the only one in execution and when this is not executed in any aggregation / streaming context. |
False
|
Source code in python/polars_ds/exprs/string.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
str_jaro(c, other, parallel=False)
Computes the Jaro similarity between this and the other str. Jaro distance = 1 - Jaro sim.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
str | Expr
|
The string column |
required |
other
|
str | Expr
|
Either the name of the column or a Polars expression. If you want to compare a single string with all of column c, use pl.lit(your_str) |
required |
parallel
|
bool
|
Whether to run it in parallel. Note that this is only recommended when this query is the only one in execution and when this is not executed in any aggregation / streaming context. |
False
|
Source code in python/polars_ds/exprs/string.py
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 | |
str_jw(c, other, weight=0.1, parallel=False)
Computes the Jaro-Winkler similarity between this and the other str. Jaro-Winkler distance = 1 - Jaro-Winkler sim.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
str | Expr
|
The string column |
required |
other
|
str | Expr
|
Either the name of the column or a Polars expression. If you want to compare a single string with all of column c, use pl.lit(your_str) |
required |
weight
|
float
|
Weight for prefix. A typical value is 0.1. |
0.1
|
parallel
|
bool
|
Whether to run it in parallel. Note that this is only recommended when this query is the only one in execution and when this is not executed in any aggregation / streaming context. |
False
|
Source code in python/polars_ds/exprs/string.py
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 | |
str_lcs_subseq(c, other, parallel=False)
Extracts the longest common subsequence from the string between this and the other string.
Note: this is not the same as the longest common substring.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
str | Expr
|
The string column |
required |
other
|
str | Expr
|
Either the name of the column or a Polars expression. If you want to compare a single string with all of column c, use pl.lit(your_str) |
required |
parallel
|
bool
|
Whether to run it in parallel. Note that this is only recommended when this query is the only one in execution and when this is not executed in any aggregation / streaming context. |
False
|
Source code in python/polars_ds/exprs/string.py
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 | |
str_lcs_subseq_dist(c, other, parallel=False, return_sim=True)
Computes the Longest Common Subsequence distance/similarity between this and the other str. The distance is calculated as max(len1, len2) - similarity, where the similarity is the the length of the longest common subsequence.
The subsequence does not need to be consecutive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
str | Expr
|
The string column |
required |
other
|
str | Expr
|
Either the name of the column or a Polars expression. If you want to compare a single string with all of column c, use pl.lit(your_str) |
required |
parallel
|
bool
|
Whether to run it in parallel. Note that this is only recommended when this query is the only one in execution and when this is not executed in any aggregation / streaming context. |
False
|
return_sim
|
bool
|
If true, return normalized similarity. |
True
|
Source code in python/polars_ds/exprs/string.py
603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 | |
str_lcs_substr(c, other, parallel=False)
Extracts the longest common substring from the string between this and the other string.
Note: this is not the same as the longest common subsequence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
str | Expr
|
The string column |
required |
other
|
str | Expr
|
Either the name of the column or a Polars expression. If you want to compare a single string with all of column c, use pl.lit(your_str) |
required |
parallel
|
bool
|
Whether to run it in parallel. Note that this is only recommended when this query is the only one in execution and when this is not executed in any aggregation / streaming context. |
False
|
Source code in python/polars_ds/exprs/string.py
547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 | |
str_leven(c, other, parallel=False, return_sim=False, as_bytes=False)
Computes the Levenshtein distance between this and the other str.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
str | Expr
|
The string column |
required |
other
|
str | Expr
|
Either the name of the column or a Polars expression. If you want to compare a single string with all of column c, use pl.lit(your_str) |
required |
parallel
|
bool
|
Whether to run it in parallel. Note that this is only recommended when this query is the only one in execution and when this is not executed in any aggregation / streaming context. |
False
|
return_sim
|
bool
|
If true, return normalized Levenshtein. |
False
|
as_bytes
|
bool
|
Whether to treat the strings as ASCII characters. This will boost performance but does not work on non-ASCII characters. |
False
|
Source code in python/polars_ds/exprs/string.py
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | |
str_nearest(c, word, threshold=100, metric='lv')
Finds the string in the column that is nearest to the given word in the given metric. This algorithm is very slow.
Note: Nearest-k strings search functionality is temporarily dropped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
str | Expr
|
The string column or its name |
required |
word
|
str
|
Any iterable collection of strings that can be turned into a polars Series, or an expression |
required |
threshold
|
int
|
Only considers strings to be near if they are within distance threshold. This is a positive integer because all the distances output integers. |
100
|
metric
|
Literal['lv', 'hamming']
|
Which similarity metric to use. One of |
'lv'
|
Source code in python/polars_ds/exprs/string.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
str_osa(c, other, parallel=False, return_sim=False)
Computes the Optimal String Alignment distance between this and the other str.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
str | Expr
|
The string column |
required |
other
|
str | Expr
|
Either the name of the column or a Polars expression. If you want to compare a single string with all of column c, use pl.lit(your_str) |
required |
parallel
|
bool
|
Whether to run it in parallel. Note that this is only recommended when this query is the only one in execution and when this is not executed in any aggregation / streaming context. |
False
|
return_sim
|
bool
|
If true, return normalized OSA similarity. |
False
|
Source code in python/polars_ds/exprs/string.py
643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 | |
str_overlap_coeff(c, other, substr_size=2, parallel=False)
Treats substrings of size substr_size as a set. And computes the overlap coefficient as
similarity between this word and the other.
Note this treats substrings at the byte level under the hood, not at the char level. So non-ASCII characters may have problems.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
str | Expr
|
The string column |
required |
other
|
str | Expr
|
Either the name of the column or a Polars expression. If you want to compare a single string with all of column c, use pl.lit(your_str) |
required |
substr_size
|
int
|
The substring size for Jaccard similarity. E.g. if substr_size = 2, "apple" will be decomposed into the set ('ap', 'pp', 'pl', 'le') before being compared. |
2
|
parallel
|
bool
|
Whether to run it in parallel. Note that this is only recommended when this query is the only one in execution and when this is not executed in any aggregation / streaming context. |
False
|
Source code in python/polars_ds/exprs/string.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | |
str_sorensen_dice(c, other, substr_size=2, parallel=False)
Treats substrings of size substr_size as a set. And computes the Sorensen-Dice similarity between
this word and the other.
Note this treats substrings at the byte level under the hood, not at the char level. So non-ASCII characters may have problems.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
str | Expr
|
The string column |
required |
other
|
str | Expr
|
Either the name of the column or a Polars expression. If you want to compare a single string with all of column c, use pl.lit(your_str) |
required |
substr_size
|
int
|
The substring size for Jaccard similarity. E.g. if substr_size = 2, "apple" will be decomposed into the set ('ap', 'pp', 'pl', 'le') before being compared. |
2
|
parallel
|
bool
|
Whether to run it in parallel. Note that this is only recommended when this query is the only one in execution and when this is not executed in any aggregation / streaming context. |
False
|
Source code in python/polars_ds/exprs/string.py
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 | |
str_tversky_sim(c, other, alpha, beta, substr_size=2, parallel=False)
Treats substrings of size substr_size as a set. And computes the tversky_sim similarity between
this word and the other. See the reference for information on how Tversky similarity is related
the other ngram based similarity.
Note this treats substrings at the byte level under the hood, not at the char level. So non-ASCII characters may have problems. Also note that alpha and beta are supposed to be weighting factors, but this doesn't check whether they satisfy the definition of weights and has to be chosen at the discretion of the user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
str | Expr
|
The string column |
required |
other
|
str | Expr
|
Either the name of the column or a Polars expression. If you want to compare a single string with all of column c, use pl.lit(your_str) |
required |
alpha
|
float
|
The first weighting factor. See reference |
required |
beta
|
float
|
The second weighting factor. See reference |
required |
substr_size
|
int
|
The substring size for Jaccard similarity. E.g. if substr_size = 2, "apple" will be decomposed into the set ('ap', 'pp', 'pl', 'le') before being compared. |
2
|
parallel
|
bool
|
Whether to run it in parallel. Note that this is only recommended when this query is the only one in execution and when this is not executed in any aggregation / streaming context. |
False
|
Reference
https://yassineelkhal.medium.com/the-complete-guide-to-string-similarity-algorithms-1290ad07c6b7
Source code in python/polars_ds/exprs/string.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | |
to_camel_case(c)
Turns itself into camel case. E.g. helloWorld
Source code in python/polars_ds/exprs/string.py
152 153 154 155 156 157 158 | |
to_constant_case(c)
Turns itself into constant case. E.g. Hello_World
Source code in python/polars_ds/exprs/string.py
179 180 181 182 183 184 185 | |
to_pascal_case(c)
Turns itself into Pascal case. E.g. HelloWorld
Source code in python/polars_ds/exprs/string.py
170 171 172 173 174 175 176 | |
to_snake_case(c)
Turns itself into snake case. E.g. hello_world
Source code in python/polars_ds/exprs/string.py
161 162 163 164 165 166 167 | |