Class: Polars::StringNameSpace
- Inherits:
-
Object
- Object
- Polars::StringNameSpace
- Defined in:
- lib/polars/string_name_space.rb
Overview
Series.str namespace.
Instance Method Summary collapse
-
#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.
-
#join(delimiter = "-", ignore_nulls: true) ⇒ Series
(also: #concat)
Vertically concat the values in the Series to a single string value.
-
#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
. -
#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
. -
#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_chars(matches = nil) ⇒ Series
Remove leading and trailing whitespace.
-
#strip_chars_end(matches = nil) ⇒ Series
(also: #rstrip)
Remove trailing whitespace.
-
#strip_chars_start(matches = nil) ⇒ Series
(also: #lstrip)
Remove leading whitespace.
-
#strptime(datatype, fmt = nil, strict: true, exact: true, cache: true) ⇒ Series
Parse a Series of dtype Utf8 to a Date/Datetime Series.
-
#to_date(format = nil, strict: true, exact: true, cache: true) ⇒ Series
Convert a Utf8 column into a Date column.
-
#to_datetime(format = nil, time_unit: nil, time_zone: nil, strict: true, exact: true, cache: true, ambiguous: "raise") ⇒ Series
Convert a Utf8 column into a Datetime column.
-
#to_lowercase ⇒ Series
Modify the strings to their lowercase equivalent.
-
#to_time(format = nil, strict: true, cache: true) ⇒ Series
Convert a Utf8 column into a Time column.
-
#to_uppercase ⇒ Series
Modify the strings to their uppercase equivalent.
-
#zfill(length) ⇒ 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
#contains(pattern, literal: false) ⇒ Series
Check if strings in Series contain a substring that matches a regex.
301 302 303 |
# File 'lib/polars/string_name_space.rb', line 301 def contains(pattern, literal: false) super end |
#count_match(pattern) ⇒ Series
Count all successive non-overlapping regex matches.
499 500 501 |
# File 'lib/polars/string_name_space.rb', line 499 def count_match(pattern) super end |
#decode(encoding, strict: false) ⇒ Series
Decode a value using the provided encoding.
372 373 374 |
# File 'lib/polars/string_name_space.rb', line 372 def decode(encoding, strict: false) super end |
#encode(encoding) ⇒ Series
Encode a value using the provided encoding.
394 395 396 |
# File 'lib/polars/string_name_space.rb', line 394 def encode(encoding) super end |
#ends_with(sub) ⇒ Series
Check if string values end with a substring.
323 324 325 |
# File 'lib/polars/string_name_space.rb', line 323 def ends_with(sub) super end |
#extract(pattern, group_index: 1) ⇒ Series
Extract the target capture group from provided patterns.
454 455 456 |
# File 'lib/polars/string_name_space.rb', line 454 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
478 479 480 |
# File 'lib/polars/string_name_space.rb', line 478 def extract_all(pattern) super end |
#join(delimiter = "-", ignore_nulls: true) ⇒ Series Also known as: concat
Vertically concat the values in the Series to a single string value.
263 264 265 |
# File 'lib/polars/string_name_space.rb', line 263 def join(delimiter = "-", ignore_nulls: true) 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.
426 427 428 |
# File 'lib/polars/string_name_space.rb', line 426 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).
207 208 209 |
# File 'lib/polars/string_name_space.rb', line 207 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
.
785 786 787 |
# File 'lib/polars/string_name_space.rb', line 785 def ljust(width, fillchar = " ") 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).
231 232 233 |
# File 'lib/polars/string_name_space.rb', line 231 def n_chars super end |
#replace(pattern, value, literal: false) ⇒ Series
Replace first matching regex/literal substring with a new string value.
637 638 639 |
# File 'lib/polars/string_name_space.rb', line 637 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.
662 663 664 |
# File 'lib/polars/string_name_space.rb', line 662 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
.
813 814 815 |
# File 'lib/polars/string_name_space.rb', line 813 def rjust(width, fillchar = " ") super end |
#slice(offset, length = nil) ⇒ Series
Create subslices of the string values of a Utf8 Series.
887 888 889 890 |
# File 'lib/polars/string_name_space.rb', line 887 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.
511 512 513 |
# File 'lib/polars/string_name_space.rb', line 511 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.
562 563 564 |
# File 'lib/polars/string_name_space.rb', line 562 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.
611 612 613 614 |
# File 'lib/polars/string_name_space.rb', line 611 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.
345 346 347 |
# File 'lib/polars/string_name_space.rb', line 345 def starts_with(sub) super end |
#strip_chars(matches = nil) ⇒ Series
Remove leading and trailing whitespace.
683 684 685 |
# File 'lib/polars/string_name_space.rb', line 683 def strip_chars(matches = nil) super end |
#strip_chars_end(matches = nil) ⇒ Series Also known as: rstrip
Remove trailing whitespace.
726 727 728 |
# File 'lib/polars/string_name_space.rb', line 726 def strip_chars_end(matches = nil) super end |
#strip_chars_start(matches = nil) ⇒ Series Also known as: lstrip
Remove leading whitespace.
704 705 706 |
# File 'lib/polars/string_name_space.rb', line 704 def strip_chars_start(matches = nil) super end |
#strptime(datatype, fmt = nil, strict: true, exact: true, cache: true) ⇒ Series
Parse a Series of dtype Utf8 to a Date/Datetime Series.
183 184 185 |
# File 'lib/polars/string_name_space.rb', line 183 def strptime(datatype, fmt = nil, strict: true, exact: true, cache: true) super end |
#to_date(format = nil, strict: true, exact: true, cache: true) ⇒ Series
Convert a Utf8 column into a Date column.
41 42 43 |
# File 'lib/polars/string_name_space.rb', line 41 def to_date(format = nil, strict: true, exact: true, cache: true) super end |
#to_datetime(format = nil, time_unit: nil, time_zone: nil, strict: true, exact: true, cache: true, ambiguous: "raise") ⇒ Series
Convert a Utf8 column into a Datetime column.
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/polars/string_name_space.rb', line 86 def to_datetime( format = nil, time_unit: nil, time_zone: nil, strict: true, exact: true, cache: true, ambiguous: "raise" ) super end |
#to_lowercase ⇒ Series
Modify the strings to their lowercase equivalent.
831 832 833 |
# File 'lib/polars/string_name_space.rb', line 831 def to_lowercase super end |
#to_time(format = nil, strict: true, cache: true) ⇒ Series
Convert a Utf8 column into a Time column.
123 124 125 |
# File 'lib/polars/string_name_space.rb', line 123 def to_time(format = nil, strict: true, cache: true) super end |
#to_uppercase ⇒ Series
Modify the strings to their uppercase equivalent.
849 850 851 |
# File 'lib/polars/string_name_space.rb', line 849 def to_uppercase super end |
#zfill(length) ⇒ 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
.
757 758 759 |
# File 'lib/polars/string_name_space.rb', line 757 def zfill(length) super end |