Class: Polars::StringNameSpace
- Inherits:
-
Object
- Object
- Polars::StringNameSpace
- Defined in:
- lib/polars/string_name_space.rb
Overview
Series.str namespace.
Instance Method Summary collapse
-
#concat(delimiter = "-") ⇒ Series
Vertically concat the values in the Series to a single string value.
-
#contains(pattern, literal: false) ⇒ Series
Check if strings in Series contain a substring that matches a regex.
-
#count_match(pattern) ⇒ Series
Count all successive non-overlapping regex matches.
-
#decode(encoding, strict: false) ⇒ Series
Decode a value using the provided encoding.
-
#encode(encoding) ⇒ Series
Encode a value using the provided encoding.
-
#ends_with(sub) ⇒ Series
Check if string values end with a substring.
-
#extract(pattern, group_index: 1) ⇒ Series
Extract the target capture group from provided patterns.
-
#extract_all(pattern) ⇒ Series
Extracts all matches for the given regex pattern.
-
#json_path_match(json_path) ⇒ Series
Extract the first match of json string with provided JSONPath expression.
-
#lengths ⇒ Series
Get length of the string values in the Series (as number of bytes).
-
#ljust(width, fillchar = " ") ⇒ Series
Return the string left justified in a string of length
width
. -
#lstrip(matches = nil) ⇒ Series
Remove leading whitespace.
-
#n_chars ⇒ Series
Get length of the string values in the Series (as number of chars).
-
#replace(pattern, value, literal: false) ⇒ Series
Replace first matching regex/literal substring with a new string value.
-
#replace_all(pattern, value, literal: false) ⇒ Series
Replace all matching regex/literal substrings with a new string value.
-
#rjust(width, fillchar = " ") ⇒ Series
Return the string right justified in a string of length
width
. -
#rstrip(matches = nil) ⇒ Series
Remove trailing whitespace.
-
#slice(offset, length = nil) ⇒ Series
Create subslices of the string values of a Utf8 Series.
-
#split(by, inclusive: false) ⇒ Series
Split the string by a substring.
-
#split_exact(by, n, inclusive: false) ⇒ Series
Split the string by a substring using
n
splits. -
#splitn(by, n) ⇒ Series
Split the string by a substring, restricted to returning at most
n
items. -
#starts_with(sub) ⇒ Series
Check if string values start with a substring.
-
#strip(matches = nil) ⇒ Series
Remove leading and trailing whitespace.
-
#strptime(datatype, fmt = nil, strict: true, exact: true, cache: true, tz_aware: false) ⇒ Series
Parse a Series of dtype Utf8 to a Date/Datetime Series.
-
#to_lowercase ⇒ Series
Modify the strings to their lowercase equivalent.
-
#to_uppercase ⇒ Series
Modify the strings to their uppercase equivalent.
-
#zfill(alignment) ⇒ Series
Fills the string with zeroes.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Polars::ExprDispatch
Instance Method Details
#concat(delimiter = "-") ⇒ Series
Vertically concat the values in the Series to a single string value.
125 126 127 |
# File 'lib/polars/string_name_space.rb', line 125 def concat(delimiter = "-") super end |
#contains(pattern, literal: false) ⇒ Series
Check if strings in Series contain a substring that matches a regex.
162 163 164 |
# File 'lib/polars/string_name_space.rb', line 162 def contains(pattern, literal: false) super end |
#count_match(pattern) ⇒ Series
Count all successive non-overlapping regex matches.
361 362 363 |
# File 'lib/polars/string_name_space.rb', line 361 def count_match(pattern) super end |
#decode(encoding, strict: false) ⇒ Series
Decode a value using the provided encoding.
233 234 235 |
# File 'lib/polars/string_name_space.rb', line 233 def decode(encoding, strict: false) super end |
#encode(encoding) ⇒ Series
Encode a value using the provided encoding.
255 256 257 |
# File 'lib/polars/string_name_space.rb', line 255 def encode(encoding) super end |
#ends_with(sub) ⇒ Series
Check if string values end with a substring.
184 185 186 |
# File 'lib/polars/string_name_space.rb', line 184 def ends_with(sub) super end |
#extract(pattern, group_index: 1) ⇒ Series
Extract the target capture group from provided patterns.
316 317 318 |
# File 'lib/polars/string_name_space.rb', line 316 def extract(pattern, group_index: 1) super end |
#extract_all(pattern) ⇒ Series
Extracts all matches for the given regex pattern.
Extract each successive non-overlapping regex match in an individual string as an array
340 341 342 |
# File 'lib/polars/string_name_space.rb', line 340 def extract_all(pattern) super end |
#json_path_match(json_path) ⇒ Series
Extract the first match of json string with provided JSONPath expression.
Throw errors if encounter invalid json strings. All return value will be casted to Utf8 regardless of the original value.
Documentation on JSONPath standard can be found here.
287 288 289 |
# File 'lib/polars/string_name_space.rb', line 287 def json_path_match(json_path) super end |
#lengths ⇒ Series
The returned lengths are equal to the number of bytes in the UTF8 string. If you
need the length in terms of the number of characters, use n_chars
instead.
Get length of the string values in the Series (as number of bytes).
87 88 89 |
# File 'lib/polars/string_name_space.rb', line 87 def lengths super end |
#ljust(width, fillchar = " ") ⇒ Series
Return the string left justified in a string of length width
.
Padding is done using the specified fillchar
. The original string is
returned if width
is less than or equal to s.length
.
605 606 607 |
# File 'lib/polars/string_name_space.rb', line 605 def ljust(width, fillchar = " ") super end |
#lstrip(matches = nil) ⇒ Series
Remove leading whitespace.
550 551 552 |
# File 'lib/polars/string_name_space.rb', line 550 def lstrip(matches = nil) super end |
#n_chars ⇒ Series
If you know that you are working with ASCII text, lengths
will be
equivalent, and faster (returns length in terms of the number of bytes).
Get length of the string values in the Series (as number of chars).
111 112 113 |
# File 'lib/polars/string_name_space.rb', line 111 def n_chars super end |
#replace(pattern, value, literal: false) ⇒ Series
Replace first matching regex/literal substring with a new string value.
505 506 507 |
# File 'lib/polars/string_name_space.rb', line 505 def replace(pattern, value, literal: false) super end |
#replace_all(pattern, value, literal: false) ⇒ Series
Replace all matching regex/literal substrings with a new string value.
530 531 532 |
# File 'lib/polars/string_name_space.rb', line 530 def replace_all(pattern, value, literal: false) super end |
#rjust(width, fillchar = " ") ⇒ Series
Return the string right justified in a string of length width
.
Padding is done using the specified fillchar
. The original string is
returned if width
is less than or equal to s.length
.
633 634 635 |
# File 'lib/polars/string_name_space.rb', line 633 def rjust(width, fillchar = " ") super end |
#rstrip(matches = nil) ⇒ Series
Remove trailing whitespace.
560 561 562 |
# File 'lib/polars/string_name_space.rb', line 560 def rstrip(matches = nil) super end |
#slice(offset, length = nil) ⇒ Series
Create subslices of the string values of a Utf8 Series.
685 686 687 688 |
# File 'lib/polars/string_name_space.rb', line 685 def slice(offset, length = nil) s = Utils.wrap_s(_s) s.to_frame.select(Polars.col(s.name).str.slice(offset, length)).to_series end |
#split(by, inclusive: false) ⇒ Series
Split the string by a substring.
373 374 375 |
# File 'lib/polars/string_name_space.rb', line 373 def split(by, inclusive: false) super end |
#split_exact(by, n, inclusive: false) ⇒ Series
Split the string by a substring using n
splits.
Results in a struct of n+1
fields.
If it cannot make n
splits, the remaining field elements will be null.
427 428 429 |
# File 'lib/polars/string_name_space.rb', line 427 def split_exact(by, n, inclusive: false) super end |
#splitn(by, n) ⇒ Series
Split the string by a substring, restricted to returning at most n
items.
If the number of possible splits is less than n-1
, the remaining field
elements will be null. If the number of possible splits is n-1
or greater,
the last (nth) substring will contain the remainder of the string.
479 480 481 482 |
# File 'lib/polars/string_name_space.rb', line 479 def splitn(by, n) s = Utils.wrap_s(_s) s.to_frame.select(Polars.col(s.name).str.splitn(by, n)).to_series end |
#starts_with(sub) ⇒ Series
Check if string values start with a substring.
206 207 208 |
# File 'lib/polars/string_name_space.rb', line 206 def starts_with(sub) super end |
#strip(matches = nil) ⇒ Series
Remove leading and trailing whitespace.
540 541 542 |
# File 'lib/polars/string_name_space.rb', line 540 def strip(matches = nil) super end |
#strptime(datatype, fmt = nil, strict: true, exact: true, cache: true, tz_aware: false) ⇒ Series
Parse a Series of dtype Utf8 to a Date/Datetime Series.
63 64 65 |
# File 'lib/polars/string_name_space.rb', line 63 def strptime(datatype, fmt = nil, strict: true, exact: true, cache: true, tz_aware: false) super end |
#to_lowercase ⇒ Series
Modify the strings to their lowercase equivalent.
640 641 642 |
# File 'lib/polars/string_name_space.rb', line 640 def to_lowercase super end |
#to_uppercase ⇒ Series
Modify the strings to their uppercase equivalent.
647 648 649 |
# File 'lib/polars/string_name_space.rb', line 647 def to_uppercase super end |
#zfill(alignment) ⇒ Series
Fills the string with zeroes.
Return a copy of the string left filled with ASCII '0' digits to make a string of length width.
A leading sign prefix ('+'/'-') is handled by inserting the padding after the
sign character rather than before. The original string is returned if width is
less than or equal to s.length
.
577 578 579 |
# File 'lib/polars/string_name_space.rb', line 577 def zfill(alignment) super end |