df-script 1.6.0 → 1.7.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.
- package/README.md +1 -1
- package/dist/api.d.ts +2 -1
- package/dist/assets/index-DBhGK6Tp.css +1 -0
- package/dist/assets/index-DEJEV_tU.js +195 -0
- package/dist/columnExpressions/ColumnExpr.d.ts +12 -5
- package/dist/columnExpressions/ExprBase.d.ts +26 -12
- package/dist/columnExpressions/constants.d.ts +1 -0
- package/dist/columnExpressions/functions/all.d.ts +23 -0
- package/dist/columnExpressions/functions/coalesce.d.ts +29 -0
- package/dist/columnExpressions/functions/element.d.ts +25 -0
- package/dist/columnExpressions/functions/exclude.d.ts +24 -0
- package/dist/columnExpressions/functions/implode.d.ts +28 -0
- package/dist/columnExpressions/functions/lit.d.ts +27 -0
- package/dist/columnExpressions/functions/seq_range.d.ts +36 -0
- package/dist/columnExpressions/functions/struct.d.ts +31 -0
- package/dist/columnExpressions/functions/when.d.ts +36 -6
- package/dist/columnExpressions/index.d.ts +1 -0
- package/dist/columnExpressions/mixins/AggregationExpr.d.ts +334 -0
- package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +609 -0
- package/dist/columnExpressions/mixins/ArrayExpr.d.ts +533 -5
- package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +353 -0
- package/dist/columnExpressions/mixins/LogicalExpr.d.ts +82 -0
- package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +40 -0
- package/dist/columnExpressions/mixins/StringExpr.d.ts +656 -3
- package/dist/columnExpressions/mixins/StructExpr.d.ts +70 -0
- package/dist/columnExpressions/mixins/TemporalExpr.d.ts +530 -4
- package/dist/columnExpressions/mixins/WindowExpr.d.ts +313 -2
- package/dist/columnExpressions/types.d.ts +1 -0
- package/dist/dataframe/dataframe.d.ts +932 -2
- package/dist/dataframe/grouped/grouped.d.ts +41 -6
- package/dist/dataframe/types.d.ts +1 -0
- package/dist/dataframe/utils.d.ts +1 -0
- package/dist/datatypes/types.d.ts +45 -0
- package/dist/exceptions/index.d.ts +23 -0
- package/dist/functions/concat.d.ts +50 -0
- package/dist/functions/read_csv.d.ts +9 -0
- package/dist/functions/read_json.d.ts +7 -2
- package/dist/index.html +17 -0
- package/dist/index.js +5 -5
- package/dist/index.mjs +6 -0
- package/dist/types.d.ts +47 -14
- package/dist/utils/array.d.ts +32 -1
- package/dist/utils/csv.d.ts +1 -0
- package/dist/utils/date.d.ts +10 -27
- package/dist/utils/json.d.ts +1 -0
- package/dist/utils/number.d.ts +1 -0
- package/dist/utils/object.d.ts +1 -0
- package/dist/utils/string.d.ts +12 -0
- package/package.json +18 -4
- package/dist/columnExpressions/mixins/ListExpr.d.ts +0 -39
- package/dist/utils/guards.d.ts +0 -13
- package/dist/utils/list.d.ts +0 -217
|
@@ -1,54 +1,707 @@
|
|
|
1
|
-
import type { IExpr } from "../../types";
|
|
1
|
+
import type { IExpr, StrptimeOptions } from "../../types";
|
|
2
2
|
import { ExprBase } from "../ExprBase";
|
|
3
3
|
import { StripCharsOptions } from "../../utils";
|
|
4
|
+
/**
|
|
5
|
+
* @namespace $df.col.str
|
|
6
|
+
* @category ColumnExpression
|
|
7
|
+
* @syntax $df.col(<column_name>).str.{symbol}(...)
|
|
8
|
+
*/
|
|
4
9
|
export declare class StringExprNamespace {
|
|
5
10
|
expr: any;
|
|
6
11
|
constructor(expr: any);
|
|
7
12
|
_deriveString(fn: (v: string) => any): any;
|
|
8
13
|
_patternGuard(pattern: any, fn: () => any): any;
|
|
14
|
+
/**
|
|
15
|
+
* Concatenates string elements with another string value or expression.
|
|
16
|
+
* @param other The string value or column expression to concatenate.
|
|
17
|
+
* @returns ColumnExpression
|
|
18
|
+
* @example
|
|
19
|
+
* >>> const df = $df.data({ first: ["John"], last: ["Doe"] })
|
|
20
|
+
* >>> df.with_columns($df.col("first").str.concat(" ").str.concat($df.col("last")).alias("full"))
|
|
21
|
+
* shape: (1, 3)
|
|
22
|
+
* ┌───────┬──────┬──────────┐
|
|
23
|
+
* │ first │ last │ full │
|
|
24
|
+
* ├───────┼──────┼──────────┤
|
|
25
|
+
* │ John │ Doe │ John Doe │
|
|
26
|
+
* └───────┴──────┴──────────┘
|
|
27
|
+
*/
|
|
9
28
|
concat(other: string | IExpr): any;
|
|
29
|
+
/**
|
|
30
|
+
* Checks if a string contains the search substring pattern (supports Regex).
|
|
31
|
+
* @param pattern The search substring or regular expression pattern.
|
|
32
|
+
* @returns ColumnExpression
|
|
33
|
+
* @example
|
|
34
|
+
* >>> const df = $df.data({ email: ["user@example.com", "admin@test.org"] })
|
|
35
|
+
* >>> df.with_columns($df.col("email").str.contains("@example.com").alias("is_example"))
|
|
36
|
+
* shape: (2, 2)
|
|
37
|
+
* ┌──────────────────┬────────────┐
|
|
38
|
+
* │ email │ is_example │
|
|
39
|
+
* ├──────────────────┼────────────┤
|
|
40
|
+
* │ user@example.com │ true │
|
|
41
|
+
* │ admin@test.org │ false │
|
|
42
|
+
* └──────────────────┴────────────┘
|
|
43
|
+
*/
|
|
10
44
|
contains(pattern: string | RegExp): any;
|
|
45
|
+
/**
|
|
46
|
+
* Counts occurrences of a substring or regular expression match in each string element.
|
|
47
|
+
* @param pattern Search substring or regular expression.
|
|
48
|
+
* @returns ColumnExpression
|
|
49
|
+
* @example
|
|
50
|
+
* >>> const df = $df.data({ code: ["banana", "apple"] })
|
|
51
|
+
* >>> df.with_columns($df.col("code").str.count_matches("a").alias("a_count"))
|
|
52
|
+
* shape: (2, 2)
|
|
53
|
+
* ┌────────┬─────────┐
|
|
54
|
+
* │ code │ a_count │
|
|
55
|
+
* ├────────┼─────────┤
|
|
56
|
+
* │ banana │ 3 │
|
|
57
|
+
* │ apple │ 1 │
|
|
58
|
+
* └────────┴─────────┘
|
|
59
|
+
*/
|
|
11
60
|
count_matches(pattern: string | RegExp): any;
|
|
61
|
+
/**
|
|
62
|
+
* Decodes Uniform Resource Identifier (URI) components.
|
|
63
|
+
* @returns ColumnExpression
|
|
64
|
+
* @example
|
|
65
|
+
* >>> const df = $df.data({ url: ["hello%20world"] })
|
|
66
|
+
* >>> df.with_columns($df.col("url").str.decode_uri_component().alias("decoded"))
|
|
67
|
+
* shape: (1, 2)
|
|
68
|
+
* ┌───────────────┬─────────────┐
|
|
69
|
+
* │ url │ decoded │
|
|
70
|
+
* ├───────────────┼─────────────┤
|
|
71
|
+
* │ hello%20world │ hello world │
|
|
72
|
+
* └───────────────┴─────────────┘
|
|
73
|
+
*/
|
|
12
74
|
decode_uri_component(): any;
|
|
75
|
+
/**
|
|
76
|
+
* Encodes Uniform Resource Identifier (URI) components.
|
|
77
|
+
* @returns ColumnExpression
|
|
78
|
+
* @example
|
|
79
|
+
* >>> const df = $df.data({ term: ["hello world"] })
|
|
80
|
+
* >>> df.with_columns($df.col("term").str.encode_uri_component().alias("encoded"))
|
|
81
|
+
* shape: (1, 2)
|
|
82
|
+
* ┌─────────────┬───────────────┐
|
|
83
|
+
* │ term │ encoded │
|
|
84
|
+
* ├─────────────┼───────────────┤
|
|
85
|
+
* │ hello world │ hello%20world │
|
|
86
|
+
* └─────────────┴───────────────┘
|
|
87
|
+
*/
|
|
13
88
|
encode_uri_component(): any;
|
|
89
|
+
/**
|
|
90
|
+
* Checks if string ends with a suffix.
|
|
91
|
+
* @param suffix The suffix substring.
|
|
92
|
+
* @returns ColumnExpression
|
|
93
|
+
* @example
|
|
94
|
+
* >>> const df = $df.data({ email: ["user@org.org", "admin@com.com"] })
|
|
95
|
+
* >>> df.with_columns($df.col("email").str.ends_with(".org").alias("is_org"))
|
|
96
|
+
* shape: (2, 2)
|
|
97
|
+
* ┌──────────────┬────────┐
|
|
98
|
+
* │ email │ is_org │
|
|
99
|
+
* ├──────────────┼────────┤
|
|
100
|
+
* │ user@org.org │ true │
|
|
101
|
+
* │ admin@com.com│ false │
|
|
102
|
+
* └──────────────┴────────┘
|
|
103
|
+
*/
|
|
14
104
|
ends_with(suffix: string): any;
|
|
105
|
+
/**
|
|
106
|
+
* Splits strings into lists of single characters.
|
|
107
|
+
* @returns ColumnExpression
|
|
108
|
+
* @example
|
|
109
|
+
* >>> const df = $df.data({ word: ["cat"] })
|
|
110
|
+
* >>> df.with_columns($df.col("word").str.explode().alias("chars"))
|
|
111
|
+
* shape: (1, 2)
|
|
112
|
+
* ┌──────┬─────────────────┐
|
|
113
|
+
* │ word │ chars │
|
|
114
|
+
* ├──────┼─────────────────┤
|
|
115
|
+
* │ cat │ ["c", "a", "t"] │
|
|
116
|
+
* └──────┴─────────────────┘
|
|
117
|
+
*/
|
|
15
118
|
explode(): any;
|
|
119
|
+
/**
|
|
120
|
+
* Extracts captured group matching a regular expression pattern.
|
|
121
|
+
* @param pattern The regex pattern containing capture groups.
|
|
122
|
+
* @param group Group index to extract (default 0 for whole match).
|
|
123
|
+
* @returns ColumnExpression
|
|
124
|
+
* @example
|
|
125
|
+
* >>> const df = $df.data({ info: ["id:123"] })
|
|
126
|
+
* >>> df.with_columns($df.col("info").str.extract(/id:(\d+)/, 1).alias("id"))
|
|
127
|
+
* shape: (1, 2)
|
|
128
|
+
* ┌────────┬─────┐
|
|
129
|
+
* │ info │ id │
|
|
130
|
+
* ├────────┼─────┤
|
|
131
|
+
* │ id:123 │ 123 │
|
|
132
|
+
* └────────┴─────┘
|
|
133
|
+
*/
|
|
16
134
|
extract(pattern: RegExp, group?: number): any;
|
|
135
|
+
/**
|
|
136
|
+
* Returns string length in UTF-16 code units. Alias for len_chars.
|
|
137
|
+
* @returns ColumnExpression
|
|
138
|
+
* @example
|
|
139
|
+
* >>> const df = $df.data({ str: ["hello"] })
|
|
140
|
+
* >>> df.with_columns($df.col("str").str.len().alias("length"))
|
|
141
|
+
* shape: (1, 2)
|
|
142
|
+
* ┌───────┬────────┐
|
|
143
|
+
* │ str │ length │
|
|
144
|
+
* ├───────┼────────┤
|
|
145
|
+
* │ hello │ 5 │
|
|
146
|
+
* └───────┴────────┘
|
|
147
|
+
*/
|
|
17
148
|
len(): any;
|
|
149
|
+
/**
|
|
150
|
+
* Returns string length in UTF-8 encoded bytes.
|
|
151
|
+
* @returns ColumnExpression
|
|
152
|
+
* @example
|
|
153
|
+
* >>> const df = $df.data({ str: ["hello"] })
|
|
154
|
+
* >>> df.with_columns($df.col("str").str.len_bytes().alias("bytes"))
|
|
155
|
+
* shape: (1, 2)
|
|
156
|
+
* ┌───────┬───────┐
|
|
157
|
+
* │ str │ bytes │
|
|
158
|
+
* ├───────┼───────┤
|
|
159
|
+
* │ hello │ 5 │
|
|
160
|
+
* └───────┴───────┘
|
|
161
|
+
*/
|
|
18
162
|
len_bytes(): any;
|
|
163
|
+
/**
|
|
164
|
+
* Returns string length in character count.
|
|
165
|
+
* @returns ColumnExpression
|
|
166
|
+
* @example
|
|
167
|
+
* >>> const df = $df.data({ text: ["hello"] })
|
|
168
|
+
* >>> df.with_columns($df.col("text").str.len_chars().alias("length"))
|
|
169
|
+
* shape: (1, 2)
|
|
170
|
+
* ┌───────┬────────┐
|
|
171
|
+
* │ text │ length │
|
|
172
|
+
* ├───────┼────────┤
|
|
173
|
+
* │ hello │ 5 │
|
|
174
|
+
* └───────┴────────┘
|
|
175
|
+
*/
|
|
19
176
|
len_chars(): any;
|
|
177
|
+
/**
|
|
178
|
+
* Converts strings to lowercase.
|
|
179
|
+
* @returns ColumnExpression
|
|
180
|
+
* @example
|
|
181
|
+
* >>> const df = $df.data({ str: ["HELLO"] })
|
|
182
|
+
* >>> df.with_columns($df.col("str").str.lower().alias("lowered"))
|
|
183
|
+
* shape: (1, 2)
|
|
184
|
+
* ┌───────┬─────────┐
|
|
185
|
+
* │ str │ lowered │
|
|
186
|
+
* ├───────┼─────────┤
|
|
187
|
+
* │ HELLO │ hello │
|
|
188
|
+
* └───────┴─────────┘
|
|
189
|
+
*/
|
|
20
190
|
lower(): any;
|
|
191
|
+
/**
|
|
192
|
+
* Pads start of strings to specified width.
|
|
193
|
+
* @param width Minimum resulting string length.
|
|
194
|
+
* @param fill Character sequence used for padding.
|
|
195
|
+
* @returns ColumnExpression
|
|
196
|
+
* @example
|
|
197
|
+
* >>> const df = $df.data({ num: ["5"] })
|
|
198
|
+
* >>> df.with_columns($df.col("num").str.lpad(3, "0").alias("padded"))
|
|
199
|
+
* shape: (1, 2)
|
|
200
|
+
* ┌─────┬────────┐
|
|
201
|
+
* │ num │ padded │
|
|
202
|
+
* ├─────┼────────┤
|
|
203
|
+
* │ 5 │ 005 │
|
|
204
|
+
* └─────┴────────┘
|
|
205
|
+
*/
|
|
21
206
|
lpad(width: number, fill?: string): any;
|
|
207
|
+
/**
|
|
208
|
+
* Pads end of strings to specified width. Alias for rpad.
|
|
209
|
+
* @param width Target string length.
|
|
210
|
+
* @param fill Character sequence used for padding.
|
|
211
|
+
* @returns ColumnExpression
|
|
212
|
+
* @example
|
|
213
|
+
* >>> const df = $df.data({ text: ["a"] })
|
|
214
|
+
* >>> df.with_columns($df.col("text").str.pad_end(3, "-").alias("padded"))
|
|
215
|
+
* shape: (1, 2)
|
|
216
|
+
* ┌──────┬────────┐
|
|
217
|
+
* │ text │ padded │
|
|
218
|
+
* ├──────┼────────┤
|
|
219
|
+
* │ a │ a-- │
|
|
220
|
+
* └──────┴────────┘
|
|
221
|
+
*/
|
|
22
222
|
pad_end(width: number, fill?: string): any;
|
|
223
|
+
/**
|
|
224
|
+
* Pads start of strings to specified width. Alias for lpad.
|
|
225
|
+
* @param width Target string length.
|
|
226
|
+
* @param fill Character sequence used for padding.
|
|
227
|
+
* @returns ColumnExpression
|
|
228
|
+
* @example
|
|
229
|
+
* >>> const df = $df.data({ num: ["5"] })
|
|
230
|
+
* >>> df.with_columns($df.col("num").str.pad_start(3, "0").alias("padded"))
|
|
231
|
+
* shape: (1, 2)
|
|
232
|
+
* ┌─────┬────────┐
|
|
233
|
+
* │ num │ padded │
|
|
234
|
+
* ├─────┼────────┤
|
|
235
|
+
* │ 5 │ 005 │
|
|
236
|
+
* └─────┴────────┘
|
|
237
|
+
*/
|
|
23
238
|
pad_start(width: number, fill?: string): any;
|
|
239
|
+
/**
|
|
240
|
+
* Replaces the first occurrence matching a string pattern.
|
|
241
|
+
* @param pattern The search pattern string or regular expression.
|
|
242
|
+
* @param replacement The string value or match replacement function.
|
|
243
|
+
* @returns ColumnExpression
|
|
244
|
+
* @example
|
|
245
|
+
* >>> const df = $df.data({ email: ["old.com"] })
|
|
246
|
+
* >>> df.with_columns($df.col("email").str.replace("old.com", "new.com").alias("updated"))
|
|
247
|
+
* shape: (1, 2)
|
|
248
|
+
* ┌─────────┬─────────┐
|
|
249
|
+
* │ email │ updated │
|
|
250
|
+
* ├─────────┼─────────┤
|
|
251
|
+
* │ old.com │ new.com │
|
|
252
|
+
* └─────────┴─────────┘
|
|
253
|
+
*/
|
|
24
254
|
replace(pattern: string | RegExp, replacement: string | ((match: string, ...args: any[]) => string)): any;
|
|
255
|
+
/**
|
|
256
|
+
* Replaces all occurrences matching a string pattern or global regular expression.
|
|
257
|
+
* @param pattern The search pattern string or regular expression.
|
|
258
|
+
* @param replacement The replacement value.
|
|
259
|
+
* @returns ColumnExpression
|
|
260
|
+
* @example
|
|
261
|
+
* >>> const df = $df.data({ text: ["foo bar foo"] })
|
|
262
|
+
* >>> df.with_columns($df.col("text").str.replace_all("foo", "baz").alias("replaced"))
|
|
263
|
+
* shape: (1, 2)
|
|
264
|
+
* ┌─────────────┬─────────────┐
|
|
265
|
+
* │ text │ replaced │
|
|
266
|
+
* ├─────────────┼─────────────┤
|
|
267
|
+
* │ foo bar foo │ baz bar baz │
|
|
268
|
+
* └─────────────┴─────────────┘
|
|
269
|
+
*/
|
|
25
270
|
replace_all(pattern: string | RegExp, replacement: string | ((match: string, ...args: any[]) => string)): any;
|
|
271
|
+
/**
|
|
272
|
+
* Reverses characters in each string element.
|
|
273
|
+
* @returns ColumnExpression
|
|
274
|
+
* @example
|
|
275
|
+
* >>> const df = $df.data({ str: ["abc"] })
|
|
276
|
+
* >>> df.with_columns($df.col("str").str.reverse().alias("rev"))
|
|
277
|
+
* shape: (1, 2)
|
|
278
|
+
* ┌─────┬─────┐
|
|
279
|
+
* │ str │ rev │
|
|
280
|
+
* ├─────┼─────┤
|
|
281
|
+
* │ abc │ cba │
|
|
282
|
+
* └─────┴─────┘
|
|
283
|
+
*/
|
|
26
284
|
reverse(): any;
|
|
285
|
+
/**
|
|
286
|
+
* Pads end of strings to specified width.
|
|
287
|
+
* @param width Minimum resulting string length.
|
|
288
|
+
* @param fill Character sequence used for padding.
|
|
289
|
+
* @returns ColumnExpression
|
|
290
|
+
* @example
|
|
291
|
+
* >>> const df = $df.data({ text: ["a"] })
|
|
292
|
+
* >>> df.with_columns($df.col("text").str.rpad(3, "-").alias("padded"))
|
|
293
|
+
* shape: (1, 2)
|
|
294
|
+
* ┌──────┬────────┐
|
|
295
|
+
* │ text │ padded │
|
|
296
|
+
* ├──────┼────────┤
|
|
297
|
+
* │ a │ a-- │
|
|
298
|
+
* └──────┴────────┘
|
|
299
|
+
*/
|
|
27
300
|
rpad(width: number, fill?: string): any;
|
|
301
|
+
/**
|
|
302
|
+
* Extracts a substring slice using start offset and length.
|
|
303
|
+
* @param offset Starting position index.
|
|
304
|
+
* @param length Number of characters to include.
|
|
305
|
+
* @returns ColumnExpression
|
|
306
|
+
* @example
|
|
307
|
+
* >>> const df = $df.data({ str: ["hello world"] })
|
|
308
|
+
* >>> df.with_columns($df.col("str").str.slice(0, 5).alias("sub"))
|
|
309
|
+
* shape: (1, 2)
|
|
310
|
+
* ┌─────────────┬───────┐
|
|
311
|
+
* │ str │ sub │
|
|
312
|
+
* ├─────────────┼───────┤
|
|
313
|
+
* │ hello world │ hello │
|
|
314
|
+
* └─────────────┴───────┘
|
|
315
|
+
*/
|
|
28
316
|
slice(offset: number, length?: number): any;
|
|
29
|
-
|
|
317
|
+
/**
|
|
318
|
+
* Splits strings into lists by delimiter.
|
|
319
|
+
* @param delimiter Substring delimiter.
|
|
320
|
+
* @returns ColumnExpression
|
|
321
|
+
* @example
|
|
322
|
+
* >>> const df = $df.data({ csv: ["a,b,c"] })
|
|
323
|
+
* >>> df.with_columns($df.col("csv").str.split(",").alias("items"))
|
|
324
|
+
* shape: (1, 2)
|
|
325
|
+
* ┌───────┬─────────────────┐
|
|
326
|
+
* │ csv │ items │
|
|
327
|
+
* ├───────┼─────────────────┤
|
|
328
|
+
* │ a,b,c │ ["a", "b", "c"] │
|
|
329
|
+
* └───────┴─────────────────┘
|
|
330
|
+
*/
|
|
30
331
|
split(delimiter: string): any;
|
|
332
|
+
/**
|
|
333
|
+
* Checks if string starts with a prefix.
|
|
334
|
+
* @param prefix The prefix substring.
|
|
335
|
+
* @returns ColumnExpression
|
|
336
|
+
* @example
|
|
337
|
+
* >>> const df = $df.data({ name: ["John Doe", "Alice"] })
|
|
338
|
+
* >>> df.with_columns($df.col("name").str.starts_with("John").alias("is_john"))
|
|
339
|
+
* shape: (2, 2)
|
|
340
|
+
* ┌──────────┬─────────┐
|
|
341
|
+
* │ name │ is_john │
|
|
342
|
+
* ├──────────┼─────────┤
|
|
343
|
+
* │ John Doe │ true │
|
|
344
|
+
* │ Alice │ false │
|
|
345
|
+
* └──────────┴─────────┘
|
|
346
|
+
*/
|
|
31
347
|
starts_with(prefix: string): any;
|
|
348
|
+
/**
|
|
349
|
+
* Strips matching characters from start and end of string.
|
|
350
|
+
* @param characters Characters or regex pattern to strip.
|
|
351
|
+
* @param options Configuration options for strip operation.
|
|
352
|
+
* @returns ColumnExpression
|
|
353
|
+
* @example
|
|
354
|
+
* >>> const df = $df.data({ text: ["--hello--"] })
|
|
355
|
+
* >>> df.with_columns($df.col("text").str.strip_chars("-").alias("stripped"))
|
|
356
|
+
* shape: (1, 2)
|
|
357
|
+
* ┌───────────┬──────────┐
|
|
358
|
+
* │ text │ stripped │
|
|
359
|
+
* ├───────────┼──────────┤
|
|
360
|
+
* │ --hello-- │ hello │
|
|
361
|
+
* └───────────┴──────────┘
|
|
362
|
+
*/
|
|
32
363
|
strip_chars(characters?: string | RegExp, options?: StripCharsOptions): any;
|
|
364
|
+
/**
|
|
365
|
+
* Strips matching characters from end of string.
|
|
366
|
+
* @param characters Characters or regex pattern to strip.
|
|
367
|
+
* @param options Configuration options.
|
|
368
|
+
* @returns ColumnExpression
|
|
369
|
+
* @example
|
|
370
|
+
* >>> const df = $df.data({ text: ["hello--"] })
|
|
371
|
+
* >>> df.with_columns($df.col("text").str.strip_chars_end("-").alias("stripped"))
|
|
372
|
+
* shape: (1, 2)
|
|
373
|
+
* ┌─────────┬──────────┐
|
|
374
|
+
* │ text │ stripped │
|
|
375
|
+
* ├─────────┼──────────┤
|
|
376
|
+
* │ hello-- │ hello │
|
|
377
|
+
* └─────────┴──────────┘
|
|
378
|
+
*/
|
|
33
379
|
strip_chars_end(characters?: string | RegExp, options?: StripCharsOptions): any;
|
|
380
|
+
/**
|
|
381
|
+
* Strips matching characters from start of string.
|
|
382
|
+
* @param characters Characters or regex pattern to strip.
|
|
383
|
+
* @param options Configuration options.
|
|
384
|
+
* @returns ColumnExpression
|
|
385
|
+
* @example
|
|
386
|
+
* >>> const df = $df.data({ text: ["--hello"] })
|
|
387
|
+
* >>> df.with_columns($df.col("text").str.strip_chars_start("-").alias("stripped"))
|
|
388
|
+
* shape: (1, 2)
|
|
389
|
+
* ┌─────────┬──────────┐
|
|
390
|
+
* │ text │ stripped │
|
|
391
|
+
* ├─────────┼──────────┤
|
|
392
|
+
* │ --hello │ hello │
|
|
393
|
+
* └─────────┴──────────┘
|
|
394
|
+
*/
|
|
34
395
|
strip_chars_start(characters?: string | RegExp, options?: StripCharsOptions): any;
|
|
396
|
+
/**
|
|
397
|
+
* Strips matching prefix substring from start of string.
|
|
398
|
+
* @param prefix Prefix substring to remove.
|
|
399
|
+
* @returns ColumnExpression
|
|
400
|
+
* @example
|
|
401
|
+
* >>> const df = $df.data({ text: ["pre_fix"] })
|
|
402
|
+
* >>> df.with_columns($df.col("text").str.strip_prefix("pre_").alias("stripped"))
|
|
403
|
+
* shape: (1, 2)
|
|
404
|
+
* ┌─────────┬──────────┐
|
|
405
|
+
* │ text │ stripped │
|
|
406
|
+
* ├─────────┼──────────┤
|
|
407
|
+
* │ pre_fix │ fix │
|
|
408
|
+
* └─────────┴──────────┘
|
|
409
|
+
*/
|
|
35
410
|
strip_prefix(prefix: string): any;
|
|
411
|
+
/**
|
|
412
|
+
* Strips matching suffix substring from end of string.
|
|
413
|
+
* @param suffix Suffix substring to remove.
|
|
414
|
+
* @returns ColumnExpression
|
|
415
|
+
* @example
|
|
416
|
+
* >>> const df = $df.data({ text: ["fix_post"] })
|
|
417
|
+
* >>> df.with_columns($df.col("text").str.strip_suffix("_post").alias("stripped"))
|
|
418
|
+
* shape: (1, 2)
|
|
419
|
+
* ┌──────────┬──────────┐
|
|
420
|
+
* │ text │ stripped │
|
|
421
|
+
* ├──────────┼──────────┤
|
|
422
|
+
* │ fix_post │ fix │
|
|
423
|
+
* └──────────┴──────────┘
|
|
424
|
+
*/
|
|
36
425
|
strip_suffix(suffix: string): any;
|
|
37
|
-
|
|
426
|
+
/**
|
|
427
|
+
* Parses date/time string into Datetime.
|
|
428
|
+
* @param options Parsing configuration options.
|
|
429
|
+
* @returns ColumnExpression
|
|
430
|
+
* @example
|
|
431
|
+
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
432
|
+
* >>> df.with_columns($df.col("d").str.strptime({ format: "%Y-%m-%d" }).alias("parsed"))
|
|
433
|
+
* shape: (1, 2)
|
|
434
|
+
* ┌────────────┬──────────────────────────┐
|
|
435
|
+
* │ d │ parsed │
|
|
436
|
+
* ├────────────┼──────────────────────────┤
|
|
437
|
+
* │ 2026-05-20 │ 2026-05-20T00:00:00.000Z │
|
|
438
|
+
* └────────────┴──────────────────────────┘
|
|
439
|
+
*/
|
|
440
|
+
strptime(options: StrptimeOptions): any;
|
|
441
|
+
/**
|
|
442
|
+
* Converts string casing to camelCase.
|
|
443
|
+
* @returns ColumnExpression
|
|
444
|
+
* @example
|
|
445
|
+
* >>> const df = $df.data({ text: ["hello_world"] })
|
|
446
|
+
* >>> df.with_columns($df.col("text").str.to_camelcase().alias("camel"))
|
|
447
|
+
* shape: (1, 2)
|
|
448
|
+
* ┌─────────────┬────────────┐
|
|
449
|
+
* │ text │ camel │
|
|
450
|
+
* ├─────────────┼────────────┤
|
|
451
|
+
* │ hello_world │ helloWorld │
|
|
452
|
+
* └─────────────┴────────────┘
|
|
453
|
+
*/
|
|
454
|
+
to_camelcase(): any;
|
|
455
|
+
/**
|
|
456
|
+
* Parses string into Date object.
|
|
457
|
+
* @returns ColumnExpression
|
|
458
|
+
* @example
|
|
459
|
+
* >>> const df = $df.data({ d: ["2026-05-20"] })
|
|
460
|
+
* >>> df.with_columns($df.col("d").str.to_date().alias("date"))
|
|
461
|
+
* shape: (1, 2)
|
|
462
|
+
* ┌────────────┬──────────────────────────┐
|
|
463
|
+
* │ d │ date │
|
|
464
|
+
* ├────────────┼──────────────────────────┤
|
|
465
|
+
* │ 2026-05-20 │ 2026-05-20T00:00:00.000Z │
|
|
466
|
+
* └────────────┴──────────────────────────┘
|
|
467
|
+
*/
|
|
38
468
|
to_date(): any;
|
|
469
|
+
/**
|
|
470
|
+
* Parses string into Datetime value.
|
|
471
|
+
* @returns ColumnExpression
|
|
472
|
+
* @example
|
|
473
|
+
* >>> const df = $df.data({ ts: ["2026-05-20T10:00:00Z"] })
|
|
474
|
+
* >>> df.with_columns($df.col("ts").str.to_datetime().alias("dt"))
|
|
475
|
+
* shape: (1, 2)
|
|
476
|
+
* ┌──────────────────────┬──────────────────────────┐
|
|
477
|
+
* │ ts │ dt │
|
|
478
|
+
* ├──────────────────────┼──────────────────────────┤
|
|
479
|
+
* │ 2026-05-20T10:00:00Z │ 2026-05-20T10:00:00.000Z │
|
|
480
|
+
* └──────────────────────┴──────────────────────────┘
|
|
481
|
+
*/
|
|
39
482
|
to_datetime(): any;
|
|
483
|
+
/**
|
|
484
|
+
* Converts string into numeric decimal representation.
|
|
485
|
+
* @param precision Optional precision limit.
|
|
486
|
+
* @param scale Optional scale limit.
|
|
487
|
+
* @returns ColumnExpression
|
|
488
|
+
* @example
|
|
489
|
+
* >>> const df = $df.data({ val: ["12.34"] })
|
|
490
|
+
* >>> df.with_columns($df.col("val").str.to_decimal().alias("num"))
|
|
491
|
+
* shape: (1, 2)
|
|
492
|
+
* ┌───────┬───────┐
|
|
493
|
+
* │ val │ num │
|
|
494
|
+
* ├───────┼───────┤
|
|
495
|
+
* │ 12.34 │ 12.34 │
|
|
496
|
+
* └───────┴───────┘
|
|
497
|
+
*/
|
|
40
498
|
to_decimal(precision?: number, scale?: number): any;
|
|
499
|
+
/**
|
|
500
|
+
* Parses string into integer number.
|
|
501
|
+
* @returns ColumnExpression
|
|
502
|
+
* @example
|
|
503
|
+
* >>> const df = $df.data({ val: ["42"] })
|
|
504
|
+
* >>> df.with_columns($df.col("val").str.to_integer().alias("num"))
|
|
505
|
+
* shape: (1, 2)
|
|
506
|
+
* ┌─────┬─────┐
|
|
507
|
+
* │ val │ num │
|
|
508
|
+
* ├─────┼─────┤
|
|
509
|
+
* │ 42 │ 42 │
|
|
510
|
+
* └─────┴─────┘
|
|
511
|
+
*/
|
|
41
512
|
to_integer(): any;
|
|
513
|
+
/**
|
|
514
|
+
* Converts string casing to kebab-case.
|
|
515
|
+
* @returns ColumnExpression
|
|
516
|
+
* @example
|
|
517
|
+
* >>> const df = $df.data({ text: ["helloWorld"] })
|
|
518
|
+
* >>> df.with_columns($df.col("text").str.to_kebabcase().alias("kebab"))
|
|
519
|
+
* shape: (1, 2)
|
|
520
|
+
* ┌────────────┬─────────────┐
|
|
521
|
+
* │ text │ kebab │
|
|
522
|
+
* ├────────────┼─────────────┤
|
|
523
|
+
* │ helloWorld │ hello-world │
|
|
524
|
+
* └────────────┴─────────────┘
|
|
525
|
+
*/
|
|
526
|
+
to_kebabcase(): any;
|
|
527
|
+
/**
|
|
528
|
+
* Converts all string elements in the column to lowercase.
|
|
529
|
+
* @returns ColumnExpression
|
|
530
|
+
* @example
|
|
531
|
+
* >>> const df = $df.data({
|
|
532
|
+
* ... c: ["ALICE", "Bob", "charlie"]
|
|
533
|
+
* ... })
|
|
534
|
+
* shape: (3, 1)
|
|
535
|
+
* ┌─────────┐
|
|
536
|
+
* │ c │
|
|
537
|
+
* ├─────────┤
|
|
538
|
+
* │ ALICE │
|
|
539
|
+
* │ Bob │
|
|
540
|
+
* │ charlie │
|
|
541
|
+
* └─────────┘
|
|
542
|
+
*
|
|
543
|
+
* >>> df.with_columns($df.col("c").str.to_lowercase().alias("lower_name"))
|
|
544
|
+
* shape: (3, 2)
|
|
545
|
+
* ┌─────────┬────────────┐
|
|
546
|
+
* │ c │ lower_name │
|
|
547
|
+
* ├─────────┼────────────┤
|
|
548
|
+
* │ ALICE │ alice │
|
|
549
|
+
* │ Bob │ bob │
|
|
550
|
+
* │ charlie │ charlie │
|
|
551
|
+
* └─────────┴────────────┘
|
|
552
|
+
*/
|
|
42
553
|
to_lowercase(): any;
|
|
554
|
+
/**
|
|
555
|
+
* Converts string casing to PascalCase.
|
|
556
|
+
* @returns ColumnExpression
|
|
557
|
+
* @example
|
|
558
|
+
* >>> const df = $df.data({ text: ["hello_world"] })
|
|
559
|
+
* >>> df.with_columns($df.col("text").str.to_pascalcase().alias("pascal"))
|
|
560
|
+
* shape: (1, 2)
|
|
561
|
+
* ┌─────────────┬────────────┐
|
|
562
|
+
* │ text │ pascal │
|
|
563
|
+
* ├─────────────┼────────────┤
|
|
564
|
+
* │ hello_world │ HelloWorld │
|
|
565
|
+
* └─────────────┴────────────┘
|
|
566
|
+
*/
|
|
567
|
+
to_pascalcase(): any;
|
|
568
|
+
/**
|
|
569
|
+
* Converts string casing to snake_case.
|
|
570
|
+
* @returns ColumnExpression
|
|
571
|
+
* @example
|
|
572
|
+
* >>> const df = $df.data({ text: ["helloWorld"] })
|
|
573
|
+
* >>> df.with_columns($df.col("text").str.to_snakecase().alias("snake"))
|
|
574
|
+
* shape: (1, 2)
|
|
575
|
+
* ┌────────────┬─────────────┐
|
|
576
|
+
* │ text │ snake │
|
|
577
|
+
* ├────────────┼─────────────┤
|
|
578
|
+
* │ helloWorld │ hello_world │
|
|
579
|
+
* └────────────┴─────────────┘
|
|
580
|
+
*/
|
|
581
|
+
to_snakecase(): any;
|
|
582
|
+
/**
|
|
583
|
+
* Parses string into time component representation.
|
|
584
|
+
* @returns ColumnExpression
|
|
585
|
+
* @example
|
|
586
|
+
* >>> const df = $df.data({ t: ["10:30:00"] })
|
|
587
|
+
* >>> df.with_columns($df.col("t").str.to_time().alias("time"))
|
|
588
|
+
* shape: (1, 2)
|
|
589
|
+
* ┌──────────┬──────────┐
|
|
590
|
+
* │ t │ time │
|
|
591
|
+
* ├──────────┼──────────┤
|
|
592
|
+
* │ 10:30:00 │ 10:30:00 │
|
|
593
|
+
* └──────────┴──────────┘
|
|
594
|
+
*/
|
|
43
595
|
to_time(): any;
|
|
596
|
+
/**
|
|
597
|
+
* Converts string casing to Title Case.
|
|
598
|
+
* @returns ColumnExpression
|
|
599
|
+
* @example
|
|
600
|
+
* >>> const df = $df.data({ text: ["hello world"] })
|
|
601
|
+
* >>> df.with_columns($df.col("text").str.to_titlecase().alias("title"))
|
|
602
|
+
* shape: (1, 2)
|
|
603
|
+
* ┌─────────────┬─────────────┐
|
|
604
|
+
* │ text │ title │
|
|
605
|
+
* ├─────────────┼─────────────┤
|
|
606
|
+
* │ hello world │ Hello World │
|
|
607
|
+
* └─────────────┴─────────────┘
|
|
608
|
+
*/
|
|
44
609
|
to_titlecase(): any;
|
|
610
|
+
/**
|
|
611
|
+
* Converts all string elements in the column to uppercase.
|
|
612
|
+
* @returns ColumnExpression
|
|
613
|
+
* @example
|
|
614
|
+
* >>> const df = $df.data({ name: ["alice"] })
|
|
615
|
+
* >>> df.with_columns($df.col("name").str.to_uppercase().alias("upper"))
|
|
616
|
+
* shape: (1, 2)
|
|
617
|
+
* ┌───────┬───────┐
|
|
618
|
+
* │ name │ upper │
|
|
619
|
+
* ├───────┼───────┤
|
|
620
|
+
* │ alice │ ALICE │
|
|
621
|
+
* └───────┴───────┘
|
|
622
|
+
*/
|
|
45
623
|
to_uppercase(): any;
|
|
624
|
+
/**
|
|
625
|
+
* Trims leading and trailing whitespace characters from each string element.
|
|
626
|
+
* @returns ColumnExpression
|
|
627
|
+
* @example
|
|
628
|
+
* >>> const df = $df.data({ name: [" alice "] })
|
|
629
|
+
* >>> df.with_columns($df.col("name").str.trim().alias("clean"))
|
|
630
|
+
* shape: (1, 2)
|
|
631
|
+
* ┌───────────┬───────┐
|
|
632
|
+
* │ name │ clean │
|
|
633
|
+
* ├───────────┼───────┤
|
|
634
|
+
* │ alice │ alice │
|
|
635
|
+
* └───────────┴───────┘
|
|
636
|
+
*/
|
|
46
637
|
trim(): any;
|
|
638
|
+
/**
|
|
639
|
+
* Trims trailing whitespace characters from each string element.
|
|
640
|
+
* @returns ColumnExpression
|
|
641
|
+
* @example
|
|
642
|
+
* >>> const df = $df.data({ name: ["alice "] })
|
|
643
|
+
* >>> df.with_columns($df.col("name").str.trim_end().alias("clean"))
|
|
644
|
+
* shape: (1, 2)
|
|
645
|
+
* ┌─────────┬───────┐
|
|
646
|
+
* │ name │ clean │
|
|
647
|
+
* ├─────────┼───────┤
|
|
648
|
+
* │ alice │ alice │
|
|
649
|
+
* └─────────┴───────┘
|
|
650
|
+
*/
|
|
47
651
|
trim_end(): any;
|
|
652
|
+
/**
|
|
653
|
+
* Trims leading whitespace characters from each string element.
|
|
654
|
+
* @returns ColumnExpression
|
|
655
|
+
* @example
|
|
656
|
+
* >>> const df = $df.data({ name: [" alice"] })
|
|
657
|
+
* >>> df.with_columns($df.col("name").str.trim_start().alias("clean"))
|
|
658
|
+
* shape: (1, 2)
|
|
659
|
+
* ┌─────────┬───────┐
|
|
660
|
+
* │ name │ clean │
|
|
661
|
+
* ├─────────┼───────┤
|
|
662
|
+
* │ alice │ alice │
|
|
663
|
+
* └─────────┴───────┘
|
|
664
|
+
*/
|
|
48
665
|
trim_start(): any;
|
|
666
|
+
/**
|
|
667
|
+
* Converts string to uppercase.
|
|
668
|
+
* @returns ColumnExpression
|
|
669
|
+
* @example
|
|
670
|
+
* >>> const df = $df.data({ text: ["alice"] })
|
|
671
|
+
* >>> df.with_columns($df.col("text").str.upper().alias("upper"))
|
|
672
|
+
* shape: (1, 2)
|
|
673
|
+
* ┌───────┬───────┐
|
|
674
|
+
* │ text │ upper │
|
|
675
|
+
* ├───────┼───────┤
|
|
676
|
+
* │ alice │ ALICE │
|
|
677
|
+
* └───────┴───────┘
|
|
678
|
+
*/
|
|
49
679
|
upper(): any;
|
|
680
|
+
/**
|
|
681
|
+
* Pads start of string with zeros to target width.
|
|
682
|
+
* @param width Minimum resulting string width.
|
|
683
|
+
* @returns ColumnExpression
|
|
684
|
+
* @example
|
|
685
|
+
* >>> const df = $df.data({ num: ["42"] })
|
|
686
|
+
* >>> df.with_columns($df.col("num").str.zfill(5).alias("padded"))
|
|
687
|
+
* shape: (1, 2)
|
|
688
|
+
* ┌─────┬────────┐
|
|
689
|
+
* │ num │ padded │
|
|
690
|
+
* ├─────┼────────┤
|
|
691
|
+
* │ 42 │ 00042 │
|
|
692
|
+
* └─────┴────────┘
|
|
693
|
+
*/
|
|
50
694
|
zfill(width: number): any;
|
|
51
695
|
}
|
|
52
696
|
export declare class StringExpr extends ExprBase {
|
|
697
|
+
/**
|
|
698
|
+
* String namespace accessor for text operations.
|
|
699
|
+
* @namespace $df.col
|
|
700
|
+
* @category ColumnExpression
|
|
701
|
+
* @syntax $df.col(<column_name>).str
|
|
702
|
+
* @returns StringExprNamespace
|
|
703
|
+
* @example
|
|
704
|
+
* >>> df.select($df.col("a").str.len())
|
|
705
|
+
*/
|
|
53
706
|
get str(): StringExprNamespace;
|
|
54
707
|
}
|