df-script 1.7.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +51 -12
  2. package/dist/api.d.ts +2 -1
  3. package/dist/columnExpressions/ExprBase.d.ts +8 -0
  4. package/dist/columnExpressions/constants.d.ts +2 -0
  5. package/dist/columnExpressions/functions/duration.d.ts +33 -0
  6. package/dist/columnExpressions/functions/when.d.ts +8 -6
  7. package/dist/columnExpressions/index.d.ts +2 -0
  8. package/dist/columnExpressions/mixins/AggregationExpr.d.ts +203 -1
  9. package/dist/columnExpressions/mixins/ArrayExpr.d.ts +57 -41
  10. package/dist/columnExpressions/mixins/StringExpr.d.ts +277 -13
  11. package/dist/columnExpressions/mixins/StructExpr.d.ts +7 -7
  12. package/dist/columnExpressions/mixins/TemporalExpr.d.ts +123 -72
  13. package/dist/columnExpressions/typeInference.d.ts +13 -0
  14. package/dist/columnExpressions/types.d.ts +1 -1
  15. package/dist/columnExpressions/utils.d.ts +19 -0
  16. package/dist/constants.d.ts +44 -3
  17. package/dist/dataframe/dataframe.d.ts +233 -109
  18. package/dist/dataframe/types.d.ts +25 -3
  19. package/dist/dataframe/utils.d.ts +21 -1
  20. package/dist/datatypes/types.d.ts +8 -3
  21. package/dist/exceptions/index.d.ts +10 -0
  22. package/dist/exceptions/utils.d.ts +2 -0
  23. package/dist/index.js +5 -5
  24. package/dist/index.mjs +5 -5
  25. package/dist/types.d.ts +132 -1
  26. package/dist/utils/array.d.ts +62 -6
  27. package/dist/utils/binary.d.ts +6 -2
  28. package/dist/utils/date.d.ts +6 -2
  29. package/dist/utils/duration.d.ts +5 -0
  30. package/dist/utils/index.d.ts +1 -0
  31. package/dist/utils/json.d.ts +54 -2
  32. package/dist/utils/number.d.ts +5 -2
  33. package/dist/utils/object.d.ts +13 -0
  34. package/dist/utils/string.d.ts +78 -2
  35. package/dist/utils/table.d.ts +76 -0
  36. package/package.json +13 -3
@@ -10,6 +10,22 @@ export declare class ArrayExprNamespace {
10
10
  expr: any;
11
11
  constructor(expr: any);
12
12
  _deriveArray(fn: (arr: any[] | AnyTypedArray) => any): any;
13
+ /**
14
+ * Applies an aggregation expression or element-wise calculation over each array cell.
15
+ * @param expr Aggregation expression (e.g. $df.element().sum() or $df.element().max())
16
+ * @returns ColumnExpression
17
+ * @example
18
+ * >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
19
+ * >>> df.with_columns($df.col("a").arr.agg($df.element().sum()).alias("sum_a"))
20
+ * shape: (2, 2)
21
+ * ┌───────────┬───────┐
22
+ * │ a │ sum_a │
23
+ * ├───────────┼───────┤
24
+ * │ [1, 2, 3] │ 6 │
25
+ * │ [4, 5] │ 9 │
26
+ * └───────────┴───────┘
27
+ */
28
+ agg(expr: IExpr): any;
13
29
  /**
14
30
  * Returns true if all items in nested list cells are truthy.
15
31
  * @returns ColumnExpression
@@ -40,6 +56,36 @@ export declare class ArrayExprNamespace {
40
56
  * └────────────────┴──────────┘
41
57
  */
42
58
  any(): any;
59
+ /**
60
+ * Finds the index of the maximum value in each array.
61
+ * @returns ColumnExpression
62
+ * @example
63
+ * >>> const df = $df.data({ a: [[1, 5, 2], [10, 4]] })
64
+ * >>> df.with_columns($df.col("a").arr.arg_max().alias("max_idx"))
65
+ * shape: (2, 2)
66
+ * ┌───────────┬─────────┐
67
+ * │ a │ max_idx │
68
+ * ├───────────┼─────────┤
69
+ * │ [1, 5, 2] │ 1 │
70
+ * │ [10, 4] │ 0 │
71
+ * └───────────┴─────────┘
72
+ */
73
+ arg_max(): any;
74
+ /**
75
+ * Finds the index of the minimum value in each array.
76
+ * @returns ColumnExpression
77
+ * @example
78
+ * >>> const df = $df.data({ a: [[5, 1, 2], [10, 4]] })
79
+ * >>> df.with_columns($df.col("a").arr.arg_min().alias("min_idx"))
80
+ * shape: (2, 2)
81
+ * ┌───────────┬─────────┐
82
+ * │ a │ min_idx │
83
+ * ├───────────┼─────────┤
84
+ * │ [5, 1, 2] │ 1 │
85
+ * │ [10, 4] │ 1 │
86
+ * └───────────┴─────────┘
87
+ */
88
+ arg_min(): any;
43
89
  /**
44
90
  * Checks if nested lists contain item.
45
91
  * @param item The element to search for.
@@ -122,20 +168,20 @@ export declare class ArrayExprNamespace {
122
168
  */
123
169
  filter(expr: IExpr): any;
124
170
  /**
125
- * Expands lists into row-wise records.
171
+ * Expands lists into row-wise elements and produces an index mapping for DataFrame unnesting.
126
172
  * @param options Config options including handling of empty arrays and nulls.
127
173
  * @returns ColumnExpression
128
174
  * @example
129
- * >>> const df = $df.data({ a: [[1, 2], [3]] })
130
- * >>> df.explode($df.col("a").arr.explode())
131
- * shape: (3, 1)
132
- * ┌───┐
133
- * │ a
134
- * ├───┤
135
- * │ 1 │
136
- * │ 2
137
- * │ 3
138
- * └───┘
175
+ * >>> const df = $df.data({ id: [1, 2], values: [[10, 20], [30]] })
176
+ * >>> df.select([$df.col("id"), $df.col("values").arr.explode()])
177
+ * shape: (3, 2)
178
+ * ┌─────┬────────┐
179
+ * │ id │ values
180
+ * ├─────┼────────┤
181
+ * │ 1 10
182
+ * │ 1 │ 20
183
+ * │ 2 │ 30
184
+ * └─────┴────────┘
139
185
  */
140
186
  explode({ empty_as_null, keep_nulls }?: ExplodeOptions): any;
141
187
  /**
@@ -271,21 +317,6 @@ export declare class ArrayExprNamespace {
271
317
  * └───────────┴───────┘
272
318
  */
273
319
  max(): any;
274
- /**
275
- * Returns the index of maximum value.
276
- * @returns ColumnExpression
277
- * @example
278
- * >>> const df = $df.data({ a: [[1, 5, 2], [10, 4]] })
279
- * >>> df.with_columns($df.col("a").arr.max_index().alias("max_idx"))
280
- * shape: (2, 2)
281
- * ┌───────────┬─────────┐
282
- * │ a │ max_idx │
283
- * ├───────────┼─────────┤
284
- * │ [1, 5, 2] │ 1 │
285
- * │ [10, 4] │ 0 │
286
- * └───────────┴─────────┘
287
- */
288
- max_index(): any;
289
320
  /**
290
321
  * Returns average of elements inside each list.
291
322
  * @returns ColumnExpression
@@ -331,21 +362,6 @@ export declare class ArrayExprNamespace {
331
362
  * └───────────┴───────┘
332
363
  */
333
364
  min(): any;
334
- /**
335
- * Returns the index of minimum value.
336
- * @returns ColumnExpression
337
- * @example
338
- * >>> const df = $df.data({ a: [[5, 1, 2], [10, 4]] })
339
- * >>> df.with_columns($df.col("a").arr.min_index().alias("min_idx"))
340
- * shape: (2, 2)
341
- * ┌───────────┬─────────┐
342
- * │ a │ min_idx │
343
- * ├───────────┼─────────┤
344
- * │ [5, 1, 2] │ 1 │
345
- * │ [10, 4] │ 1 │
346
- * └───────────┴─────────┘
347
- */
348
- min_index(): any;
349
365
  /**
350
366
  * Returns the mode value inside each list.
351
367
  * @returns ColumnExpression
@@ -1,6 +1,6 @@
1
- import type { IExpr, StrptimeOptions } from "../../types";
1
+ import type { IExpr, StrptimeOptions, StringDecodeOptions, StringEncodeOptions, EscapeRegexOptions, ExtractManyOptions, ExtractRegexEngineOptions, FindOptions, FindManyOptions, SplitOptions, ReplaceOptions, ReplaceManyOptions } from "../../types";
2
2
  import { ExprBase } from "../ExprBase";
3
- import { StripCharsOptions } from "../../utils";
3
+ import { StripCharsOptions, JoinArrayOptions, SafeJsonParseOptions } from "../../utils";
4
4
  /**
5
5
  * @namespace $df.col.str
6
6
  * @category ColumnExpression
@@ -11,6 +11,7 @@ export declare class StringExprNamespace {
11
11
  constructor(expr: any);
12
12
  _deriveString(fn: (v: string) => any): any;
13
13
  _patternGuard(pattern: any, fn: () => any): any;
14
+ _matchPattern(str: string, pattern: string | RegExp): boolean;
14
15
  /**
15
16
  * Concatenates string elements with another string value or expression.
16
17
  * @param other The string value or column expression to concatenate.
@@ -42,6 +43,22 @@ export declare class StringExprNamespace {
42
43
  * └──────────────────┴────────────┘
43
44
  */
44
45
  contains(pattern: string | RegExp): any;
46
+ /**
47
+ * Checks if a string contains any of the search patterns.
48
+ * @param patterns Array of substring or regular expression search patterns.
49
+ * @returns ColumnExpression
50
+ * @example
51
+ * >>> const df = $df.data({ email: ["user@example.com", "admin@test.org"] })
52
+ * >>> df.with_columns($df.col("email").str.contains_any(["@example.com", "@test.org"]).alias("is_target"))
53
+ * shape: (2, 2)
54
+ * ┌──────────────────┬───────────┐
55
+ * │ email │ is_target │
56
+ * ├──────────────────┼───────────┤
57
+ * │ user@example.com │ true │
58
+ * │ admin@test.org │ true │
59
+ * └──────────────────┴───────────┘
60
+ */
61
+ contains_any(patterns: (string | RegExp)[]): any;
45
62
  /**
46
63
  * Counts occurrences of a substring or regular expression match in each string element.
47
64
  * @param pattern Search substring or regular expression.
@@ -57,7 +74,54 @@ export declare class StringExprNamespace {
57
74
  * │ apple │ 1 │
58
75
  * └────────┴─────────┘
59
76
  */
60
- count_matches(pattern: string | RegExp): any;
77
+ count_matches(pattern: string | RegExp | any, options?: {
78
+ literal?: boolean;
79
+ } | boolean): any;
80
+ /**
81
+ * Escapes special regular expression characters in string elements.
82
+ * @returns ColumnExpression
83
+ * @example
84
+ * >>> const df = $df.data({ pat: ["a.b", "c$d"] })
85
+ * >>> df.with_columns($df.col("pat").str.escape_regex().alias("escaped"))
86
+ * shape: (2, 2)
87
+ * ┌───────┬─────────┐
88
+ * │ pat │ escaped │
89
+ * ├───────┼─────────┤
90
+ * │ a.b │ a\.b │
91
+ * │ c$d │ c\$d │
92
+ * └───────┴─────────┘
93
+ */
94
+ escape_regex(options?: EscapeRegexOptions): any;
95
+ /**
96
+ * Decodes hex or base64 encoded string column values into string.
97
+ * @param options Object containing encoding ("hex" | "base64") and optional strict flag
98
+ * @returns ColumnExpression
99
+ * @example
100
+ * >>> const df = $df.data({ encoded: ["68656c6c6f"] })
101
+ * >>> df.with_columns($df.col("encoded").str.decode({ encoding: "hex" }).alias("decoded"))
102
+ * shape: (1, 2)
103
+ * ┌────────────┬─────────┐
104
+ * │ encoded │ decoded │
105
+ * ├────────────┼─────────┤
106
+ * │ 68656c6c6f │ hello │
107
+ * └────────────┴─────────┘
108
+ */
109
+ decode(options: StringDecodeOptions): any;
110
+ /**
111
+ * Encodes string column values into hex or base64.
112
+ * @param options Object containing encoding ("hex" | "base64")
113
+ * @returns ColumnExpression
114
+ * @example
115
+ * >>> const df = $df.data({ text: ["hello"] })
116
+ * >>> df.with_columns($df.col("text").str.encode({ encoding: "hex" }).alias("encoded"))
117
+ * shape: (1, 2)
118
+ * ┌───────┬────────────┐
119
+ * │ text │ encoded │
120
+ * ├───────┼────────────┤
121
+ * │ hello │ 68656c6c6f │
122
+ * └───────┴────────────┘
123
+ */
124
+ encode(options: StringEncodeOptions): any;
61
125
  /**
62
126
  * Decodes Uniform Resource Identifier (URI) components.
63
127
  * @returns ColumnExpression
@@ -117,13 +181,13 @@ export declare class StringExprNamespace {
117
181
  */
118
182
  explode(): any;
119
183
  /**
120
- * Extracts captured group matching a regular expression pattern.
184
+ * Extracts a captured group from the first regex match.
121
185
  * @param pattern The regex pattern containing capture groups.
122
- * @param group Group index to extract (default 0 for whole match).
186
+ * @param options Options object. Use `groupIndex` to select the group (default 1).
123
187
  * @returns ColumnExpression
124
188
  * @example
125
189
  * >>> const df = $df.data({ info: ["id:123"] })
126
- * >>> df.with_columns($df.col("info").str.extract(/id:(\d+)/, 1).alias("id"))
190
+ * >>> df.with_columns($df.col("info").str.extract(/id:(\d+)/).alias("id"))
127
191
  * shape: (1, 2)
128
192
  * ┌────────┬─────┐
129
193
  * │ info │ id │
@@ -131,7 +195,154 @@ export declare class StringExprNamespace {
131
195
  * │ id:123 │ 123 │
132
196
  * └────────┴─────┘
133
197
  */
134
- extract(pattern: RegExp, group?: number): any;
198
+ extract(pattern: RegExp | string, options?: ExtractRegexEngineOptions): any;
199
+ /**
200
+ * Extracts all occurrences matching a regular expression pattern.
201
+ * @param pattern Search pattern (string or RegExp).
202
+ * @param options Options object. Use `groupIndex` to select the group (default 0).
203
+ * @returns ColumnExpression
204
+ * @example
205
+ * >>> const df = $df.data({ text: ["foo 123 bar 456"] })
206
+ * >>> df.with_columns($df.col("text").str.extract_all(/\d+/).alias("nums"))
207
+ * shape: (1, 2)
208
+ * ┌─────────────────┬──────────────┐
209
+ * │ text │ nums │
210
+ * ├─────────────────┼──────────────┤
211
+ * │ foo 123 bar 456 │ [123, 456] │
212
+ * └─────────────────┴──────────────┘
213
+ */
214
+ extract_all(pattern: string | RegExp, options?: ExtractRegexEngineOptions): any;
215
+ /**
216
+ * Extracts all captured groups from the first regex match into a structured object (struct).
217
+ * @param pattern Search pattern containing capture groups.
218
+ * @returns ColumnExpression
219
+ * @example
220
+ * >>> const df = $df.data({ info: ["id:123-name:alice"] })
221
+ * >>> df.with_columns($df.col("info").str.extract_groups(/(?<id>\d+)-(?<name>\w+)/).alias("parsed"))
222
+ * shape: (1, 2)
223
+ * ┌────────────────────┬─────────────────────────────┐
224
+ * │ info │ parsed │
225
+ * ├────────────────────┼─────────────────────────────┤
226
+ * │ id:123-name:alice │ { id: "123", name: "alice" }│
227
+ * └────────────────────┴─────────────────────────────┘
228
+ */
229
+ extract_groups(pattern: string | RegExp, options?: ExtractManyOptions): any;
230
+ /**
231
+ * Extracts the first regex match for each pattern in a list of patterns.
232
+ * @param patterns Array of regular expression patterns or strings.
233
+ * @param options Named options object ({ asciiCaseInsensitive, overlapping }).
234
+ * @returns ColumnExpression
235
+ * @example
236
+ * >>> const df = $df.data({ text: ["user_123_PROD"] })
237
+ * >>> df.with_columns($df.col("text").str.extract_many([/user_\d+/, /prod/], { asciiCaseInsensitive: true }).alias("extracted"))
238
+ * shape: (1, 2)
239
+ * ┌───────────────┬──────────────────────────┐
240
+ * │ text │ extracted │
241
+ * ├───────────────┼──────────────────────────┤
242
+ * │ user_123_PROD │ ["user_123", "PROD"] │
243
+ * └───────────────┴──────────────────────────┘
244
+ */
245
+ extract_many(patterns: (string | RegExp)[], options?: ExtractManyOptions): any;
246
+ /**
247
+ * Return the byte offset of the first substring matching a pattern.
248
+ * Returns null if pattern is not found.
249
+ * @param value Search string or regular expression.
250
+ * @param options Configuration options ({ literal, asciiCaseInsensitive }).
251
+ * @returns ColumnExpression
252
+ * @example
253
+ * >>> const df = $df.data({ text: ["user_123_PROD"] })
254
+ * >>> df.with_columns($df.col("text").str.find(/\d+/).alias("pos"))
255
+ * shape: (1, 2)
256
+ * ┌───────────────┬─────┐
257
+ * │ text │ pos │
258
+ * ├───────────────┼─────┤
259
+ * │ user_123_PROD │ 5 │
260
+ * └───────────────┴─────┘
261
+ */
262
+ find(value: string | RegExp, options?: FindOptions): any;
263
+ /**
264
+ * Return the starting byte offset of each match for multiple patterns.
265
+ * @param patterns Array of regular expressions or literal search strings.
266
+ * @param options Configuration options ({ literal, asciiCaseInsensitive, overlapping, leftmost }).
267
+ * @returns ColumnExpression
268
+ * @example
269
+ * >>> const df = $df.data({ text: ["user_123_PROD"] })
270
+ * >>> df.with_columns($df.col("text").str.find_many([/user_\d+/, /PROD/]).alias("positions"))
271
+ * shape: (1, 2)
272
+ * ┌───────────────┬───────────┐
273
+ * │ text │ positions │
274
+ * ├───────────────┼───────────┤
275
+ * │ user_123_PROD │ [0, 9] │
276
+ * └───────────────┴───────────┘
277
+ */
278
+ find_many(patterns: (string | RegExp)[], options?: FindManyOptions): any;
279
+ /**
280
+ * Extracts the first n characters of each string element.
281
+ * @param n Number of characters to extract from the start of the string (default 1).
282
+ * @returns ColumnExpression
283
+ * @example
284
+ * >>> const df = $df.data({ name: ["polars", "javascript"] })
285
+ * >>> df.with_columns($df.col("name").str.head(3).alias("prefix"))
286
+ * shape: (2, 2)
287
+ * ┌────────────┬────────┐
288
+ * │ name │ prefix │
289
+ * ├────────────┼────────┤
290
+ * │ polars │ pol │
291
+ * │ javascript │ jav │
292
+ * └────────────┴────────┘
293
+ */
294
+ head(n?: number): any;
295
+ /**
296
+ * Joins a list of string elements into a single string using a delimiter.
297
+ * Accepts `JoinArrayOptions` (`{ ignoreNulls, nullValue, prefix, suffix, limit, truncationMarker, valueFormatter }`).
298
+ * @param delimiter The string delimiter to join elements with.
299
+ * @param options Formatting configuration options (`JoinArrayOptions`).
300
+ * @returns ColumnExpression
301
+ * @example
302
+ * >>> const df = $df.data({ tags: [["a", "b", "c"], ["x", "y"]] })
303
+ * >>> df.with_columns($df.col("tags").str.join("-").alias("joined"))
304
+ * shape: (2, 2)
305
+ * ┌─────────────────┬──────────┐
306
+ * │ tags │ joined │
307
+ * ├─────────────────┼──────────┤
308
+ * │ ["a", "b", "c"] │ a-b-c │
309
+ * │ ["x", "y"] │ x-y │
310
+ * └─────────────────┴──────────┘
311
+ */
312
+ join(delimiter?: string, options?: JoinArrayOptions): any;
313
+ /**
314
+ * Decodes JSON string elements into parsed objects or arrays.
315
+ * Reuses safeJsonParse utility.
316
+ * @param options Configuration options for parsing (`SafeJsonParseOptions`).
317
+ * @returns ColumnExpression
318
+ * @example
319
+ * >>> const df = $df.data({ json_str: ['{"a": 1}', '{"b": 2}'] })
320
+ * >>> df.with_columns($df.col("json_str").str.json_decode().alias("parsed"))
321
+ * shape: (2, 2)
322
+ * ┌────────────┬───────────┐
323
+ * │ json_str │ parsed │
324
+ * ├────────────┼───────────┤
325
+ * │ {"a": 1} │ { a: 1 } │
326
+ * │ {"b": 2} │ { b: 2 } │
327
+ * └────────────┴───────────┘
328
+ */
329
+ json_decode(options?: SafeJsonParseOptions): any;
330
+ /**
331
+ * Extracts fields or array elements from JSON strings using JSONPath syntax.
332
+ * @param jsonPath The JSONPath expression (e.g. `"$.store.book[0].title"` or `"$.a.b"`).
333
+ * @returns ColumnExpression
334
+ * @example
335
+ * >>> const df = $df.data({ json_str: ['{"a": {"b": 10}}', '{"a": {"b": 20}}'] })
336
+ * >>> df.with_columns($df.col("json_str").str.json_path_match("$.a.b").alias("val"))
337
+ * shape: (2, 2)
338
+ * ┌────────────────────┬─────┐
339
+ * │ json_str │ val │
340
+ * ├────────────────────┼─────┤
341
+ * │ {"a": {"b": 10}} │ 10 │
342
+ * │ {"a": {"b": 20}} │ 20 │
343
+ * └────────────────────┴─────┘
344
+ */
345
+ json_path_match(jsonPath: string): any;
135
346
  /**
136
347
  * Returns string length in UTF-16 code units. Alias for len_chars.
137
348
  * @returns ColumnExpression
@@ -204,6 +415,22 @@ export declare class StringExprNamespace {
204
415
  * └─────┴────────┘
205
416
  */
206
417
  lpad(width: number, fill?: string): any;
418
+ /**
419
+ * Normalizes Unicode strings using standard normalization forms (NFC, NFD, NFKC, NFKD).
420
+ * @param form The Unicode normalization form to apply ("NFC", "NFD", "NFKC", or "NFKD"). Default is "NFC".
421
+ * @returns ColumnExpression
422
+ * @throws InvalidArgumentError If an invalid normalization form is provided.
423
+ * @example
424
+ * >>> const df = $df.data({ str: ["e\u0301"] })
425
+ * >>> df.with_columns($df.col("str").str.normalize("NFC").alias("normalized"))
426
+ * shape: (1, 2)
427
+ * ┌───────┬────────────┐
428
+ * │ str │ normalized │
429
+ * ├───────┼────────────┤
430
+ * │ é │ é │
431
+ * └───────┴────────────┘
432
+ */
433
+ normalize(form?: Parameters<typeof String.prototype.normalize>[0]): any;
207
434
  /**
208
435
  * Pads end of strings to specified width. Alias for rpad.
209
436
  * @param width Target string length.
@@ -240,6 +467,7 @@ export declare class StringExprNamespace {
240
467
  * Replaces the first occurrence matching a string pattern.
241
468
  * @param pattern The search pattern string or regular expression.
242
469
  * @param replacement The string value or match replacement function.
470
+ * @param options Optional replace options (literal, asciiCaseInsensitive, n).
243
471
  * @returns ColumnExpression
244
472
  * @example
245
473
  * >>> const df = $df.data({ email: ["old.com"] })
@@ -251,11 +479,12 @@ export declare class StringExprNamespace {
251
479
  * │ old.com │ new.com │
252
480
  * └─────────┴─────────┘
253
481
  */
254
- replace(pattern: string | RegExp, replacement: string | ((match: string, ...args: any[]) => string)): any;
482
+ replace(pattern: string | RegExp, replacement: string | ((match: string, ...args: any[]) => string), options?: ReplaceOptions): any;
255
483
  /**
256
484
  * Replaces all occurrences matching a string pattern or global regular expression.
257
485
  * @param pattern The search pattern string or regular expression.
258
486
  * @param replacement The replacement value.
487
+ * @param options Optional replace options (literal, asciiCaseInsensitive).
259
488
  * @returns ColumnExpression
260
489
  * @example
261
490
  * >>> const df = $df.data({ text: ["foo bar foo"] })
@@ -267,7 +496,25 @@ export declare class StringExprNamespace {
267
496
  * │ foo bar foo │ baz bar baz │
268
497
  * └─────────────┴─────────────┘
269
498
  */
270
- replace_all(pattern: string | RegExp, replacement: string | ((match: string, ...args: any[]) => string)): any;
499
+ replace_all(pattern: string | RegExp, replacement: string | ((match: string, ...args: any[]) => string), options?: Omit<ReplaceOptions, "n">): any;
500
+ /**
501
+ * Replaces multiple string patterns simultaneously or sequentially with their respective replacements.
502
+ * Matches Polars `.str.replace_many()` behavior, accepting pattern/replacement arrays or a pattern-to-replacement map dictionary.
503
+ * @param patterns Array of patterns or an object mapping target patterns to replacements.
504
+ * @param replacements Array of replacement strings/callbacks (when patterns is an array).
505
+ * @param options Configuration options ({ literal, asciiCaseInsensitive, mode }).
506
+ * @returns ColumnExpression
507
+ * @example
508
+ * >>> const df = $df.data({ text: ["foo bar baz"] })
509
+ * >>> df.with_columns($df.col("text").str.replace_many(["foo", "bar"], ["1", "2"]).alias("res"))
510
+ * shape: (1, 2)
511
+ * ┌─────────────┬─────────┐
512
+ * │ text │ res │
513
+ * ├─────────────┼─────────┤
514
+ * │ foo bar baz │ 1 2 baz │
515
+ * └─────────────┴─────────┘
516
+ */
517
+ replace_many(patterns: (string | RegExp)[] | Record<string, string>, replacements?: (string | ((match: string, ...args: any[]) => string))[], options?: ReplaceManyOptions): any;
271
518
  /**
272
519
  * Reverses characters in each string element.
273
520
  * @returns ColumnExpression
@@ -315,20 +562,21 @@ export declare class StringExprNamespace {
315
562
  */
316
563
  slice(offset: number, length?: number): any;
317
564
  /**
318
- * Splits strings into lists by delimiter.
565
+ * Splits strings into lists by delimiter with optional limit and exact padding.
319
566
  * @param delimiter Substring delimiter.
567
+ * @param options Options for controlling limit and exact padding.
320
568
  * @returns ColumnExpression
321
569
  * @example
322
570
  * >>> const df = $df.data({ csv: ["a,b,c"] })
323
- * >>> df.with_columns($df.col("csv").str.split(",").alias("items"))
571
+ * >>> df.with_columns($df.col("csv").str.split(",", { limit: 1 }).alias("items"))
324
572
  * shape: (1, 2)
325
573
  * ┌───────┬─────────────────┐
326
574
  * │ csv │ items │
327
575
  * ├───────┼─────────────────┤
328
- * │ a,b,c │ ["a", "b", "c"]
576
+ * │ a,b,c │ ["a", "b,c"]
329
577
  * └───────┴─────────────────┘
330
578
  */
331
- split(delimiter: string): any;
579
+ split(delimiter: string, options?: SplitOptions): any;
332
580
  /**
333
581
  * Checks if string starts with a prefix.
334
582
  * @param prefix The prefix substring.
@@ -423,6 +671,22 @@ export declare class StringExprNamespace {
423
671
  * └──────────┴──────────┘
424
672
  */
425
673
  strip_suffix(suffix: string): any;
674
+ /**
675
+ * Extracts the last n characters of each string element.
676
+ * @param n Number of characters to extract from the end of the string (default 1).
677
+ * @returns ColumnExpression
678
+ * @example
679
+ * >>> const df = $df.data({ name: ["polars", "javascript"] })
680
+ * >>> df.with_columns($df.col("name").str.tail(3).alias("suffix"))
681
+ * shape: (2, 2)
682
+ * ┌────────────┬────────┐
683
+ * │ name │ suffix │
684
+ * ├────────────┼────────┤
685
+ * │ polars │ ars │
686
+ * │ javascript │ ipt │
687
+ * └────────────┴────────┘
688
+ */
689
+ tail(n?: number): any;
426
690
  /**
427
691
  * Parses date/time string into Datetime.
428
692
  * @param options Parsing configuration options.
@@ -1,13 +1,13 @@
1
1
  import { ExprBase } from "../ExprBase";
2
- import type { IntoExpr, IExpr } from "../../types";
2
+ import type { IntoExpr } from "../../types";
3
3
  /**
4
4
  * @namespace $df.col.struct
5
5
  * @category ColumnExpression
6
6
  * @syntax $df.col(<column_name>).struct.{symbol}(...)
7
7
  */
8
8
  export declare class StructExprNamespace {
9
- expr: IExpr;
10
- constructor(expr: IExpr);
9
+ expr: any;
10
+ constructor(expr: any);
11
11
  /**
12
12
  * Extracts a sub-field property value from nested objects/struct columns.
13
13
  * @param name Name of the field key to extract.
@@ -22,7 +22,7 @@ export declare class StructExprNamespace {
22
22
  * │ { name: "Alice", id: 1 }│ Alice │
23
23
  * └─────────────────────────┴───────────┘
24
24
  */
25
- field(name: string): IExpr;
25
+ field(name: string): any;
26
26
  /**
27
27
  * Renames existing field keys inside structured object columns.
28
28
  * @param mapping Key-value map of current field names to new field names.
@@ -37,7 +37,7 @@ export declare class StructExprNamespace {
37
37
  * │ { first: "Alice" }│ { first_name: "Alice" } │
38
38
  * └───────────────────┴─────────────────────────┘
39
39
  */
40
- rename_fields(mapping: Record<string, string>): IExpr;
40
+ rename_fields(mapping: Record<string, string>): any;
41
41
  /**
42
42
  * Inserts or updates fields inside structured object columns.
43
43
  * @param fields Expressions or field map defining new or updated fields.
@@ -53,7 +53,7 @@ export declare class StructExprNamespace {
53
53
  * │ { name: "Alice"}│ 30 │ { name: "Alice", user_age: 30}│
54
54
  * └─────────────────┴─────┴───────────────────────────────┘
55
55
  */
56
- with_fields(fields: IntoExpr[] | Record<string, IntoExpr>): IExpr;
56
+ with_fields(fields: IntoExpr[] | Record<string, IntoExpr>): any;
57
57
  /**
58
58
  * Expands nested struct attributes into distinct columns in the DataFrame schema.
59
59
  * @returns ColumnExpression
@@ -67,7 +67,7 @@ export declare class StructExprNamespace {
67
67
  * │ Alice │ 30 │
68
68
  * └───────┴─────┘
69
69
  */
70
- unnest(): IExpr;
70
+ unnest(): any;
71
71
  }
72
72
  export interface StructExprNamespace {
73
73
  [key: string]: any;