df-script 1.9.0 → 2.0.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 +148 -235
- package/dist/api.d.ts +41 -36
- package/dist/columnExpressions/ColumnExpr.d.ts +5 -8
- package/dist/columnExpressions/functions/all.d.ts +13 -13
- package/dist/columnExpressions/functions/coalesce.d.ts +2 -2
- package/dist/columnExpressions/functions/duration.d.ts +16 -21
- package/dist/columnExpressions/functions/element.d.ts +10 -10
- package/dist/columnExpressions/functions/exclude.d.ts +14 -14
- package/dist/columnExpressions/functions/implode.d.ts +7 -7
- package/dist/columnExpressions/functions/lit.d.ts +9 -9
- package/dist/columnExpressions/functions/seqRange.d.ts +69 -0
- package/dist/columnExpressions/functions/struct.d.ts +6 -6
- package/dist/columnExpressions/functions/when.d.ts +25 -28
- package/dist/columnExpressions/index.d.ts +3 -7
- package/dist/columnExpressions/mixins/AggregationExpr.d.ts +550 -221
- package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +701 -327
- package/dist/columnExpressions/mixins/ArrayExpr.d.ts +508 -212
- package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +398 -201
- package/dist/columnExpressions/mixins/LogicalExpr.d.ts +59 -29
- package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +23 -9
- package/dist/columnExpressions/mixins/StandardExpr.d.ts +3234 -0
- package/dist/columnExpressions/mixins/StringExpr.d.ts +1163 -524
- package/dist/columnExpressions/mixins/StructExpr.d.ts +67 -25
- package/dist/columnExpressions/mixins/TemporalExpr.d.ts +518 -212
- package/dist/columnExpressions/mixins/WindowExpr.d.ts +270 -102
- package/dist/columnExpressions/typeInference.d.ts +3 -3
- package/dist/columnExpressions/types.d.ts +5 -0
- package/dist/columnExpressions/utils.d.ts +7 -0
- package/dist/constants.d.ts +11 -2
- package/dist/dataframe/dataframe.d.ts +755 -592
- package/dist/dataframe/grouped/grouped.d.ts +24 -6
- package/dist/dataframe/grouped.d.ts +70 -0
- package/dist/dataframe/index.d.ts +1 -1
- package/dist/dataframe/lazy.d.ts +37 -0
- package/dist/dataframe/types.d.ts +46 -22
- package/dist/dataframe/utils.d.ts +10 -4
- package/dist/datatypes/index.d.ts +11 -4
- package/dist/expressions.js +1 -0
- package/dist/expressions.mjs +1 -0
- package/dist/functions/concat.d.ts +68 -16
- package/dist/functions/index.d.ts +2 -2
- package/dist/functions/readCsv.d.ts +35 -0
- package/dist/functions/readJson.d.ts +33 -0
- package/dist/index.js +5 -6
- package/dist/index.mjs +5 -6
- package/dist/types.d.ts +42 -9
- package/dist/utils/array.d.ts +17 -14
- package/dist/utils/csv.d.ts +4 -1
- package/dist/utils/date.d.ts +3 -19
- package/dist/utils/duration.d.ts +7 -5
- package/dist/utils/json.d.ts +5 -3
- package/dist/utils/object.d.ts +0 -18
- package/dist/utils/string.d.ts +5 -0
- package/dist/utils.js +4 -0
- package/dist/utils.mjs +4 -0
- package/package.json +29 -8
- package/dist/assets/index-DBhGK6Tp.css +0 -1
- package/dist/assets/index-DEJEV_tU.js +0 -195
- package/dist/index.html +0 -17
|
@@ -17,14 +17,25 @@ export declare class StringExprNamespace {
|
|
|
17
17
|
* @param other The string value or column expression to concatenate.
|
|
18
18
|
* @returns ColumnExpression
|
|
19
19
|
* @example
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
21
|
+
* >>> df
|
|
22
|
+
* shape: (3, 1)
|
|
23
|
+
* ┌──────────┐
|
|
24
|
+
* │ s │
|
|
25
|
+
* ├──────────┤
|
|
26
|
+
* │ "apple" │
|
|
27
|
+
* │ "banana" │
|
|
28
|
+
* │ "cherry" │
|
|
29
|
+
* └──────────┘
|
|
30
|
+
* >>> df.withColumns($df.col("s").str.concat("!").alias("exclaimed"))
|
|
31
|
+
* shape: (3, 2)
|
|
32
|
+
* ┌──────────┬───────────┐
|
|
33
|
+
* │ s │ exclaimed │
|
|
34
|
+
* ├──────────┼───────────┤
|
|
35
|
+
* │ "apple" │ apple! │
|
|
36
|
+
* │ "banana" │ banana! │
|
|
37
|
+
* │ "cherry" │ cherry! │
|
|
38
|
+
* └──────────┴───────────┘
|
|
28
39
|
*/
|
|
29
40
|
concat(other: string | IExpr): any;
|
|
30
41
|
/**
|
|
@@ -32,8 +43,17 @@ export declare class StringExprNamespace {
|
|
|
32
43
|
* @param pattern The search substring or regular expression pattern.
|
|
33
44
|
* @returns ColumnExpression
|
|
34
45
|
* @example
|
|
35
|
-
|
|
36
|
-
|
|
46
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
47
|
+
* >>> df
|
|
48
|
+
* shape: (3, 1)
|
|
49
|
+
* ┌──────────┐
|
|
50
|
+
* │ s │
|
|
51
|
+
* ├──────────┤
|
|
52
|
+
* │ "apple" │
|
|
53
|
+
* │ "banana" │
|
|
54
|
+
* │ "cherry" │
|
|
55
|
+
* └──────────┘
|
|
56
|
+
* >>> df.withColumns($df.col("email").str.contains("@example.com").alias("is_example"))
|
|
37
57
|
* shape: (2, 2)
|
|
38
58
|
* ┌──────────────────┬────────────┐
|
|
39
59
|
* │ email │ is_example │
|
|
@@ -48,8 +68,17 @@ export declare class StringExprNamespace {
|
|
|
48
68
|
* @param patterns Array of substring or regular expression search patterns.
|
|
49
69
|
* @returns ColumnExpression
|
|
50
70
|
* @example
|
|
51
|
-
|
|
52
|
-
|
|
71
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
72
|
+
* >>> df
|
|
73
|
+
* shape: (3, 1)
|
|
74
|
+
* ┌──────────┐
|
|
75
|
+
* │ s │
|
|
76
|
+
* ├──────────┤
|
|
77
|
+
* │ "apple" │
|
|
78
|
+
* │ "banana" │
|
|
79
|
+
* │ "cherry" │
|
|
80
|
+
* └──────────┘
|
|
81
|
+
* >>> df.withColumns($df.col("email").str.containsAny(["@example.com", "@test.org"]).alias("is_target"))
|
|
53
82
|
* shape: (2, 2)
|
|
54
83
|
* ┌──────────────────┬───────────┐
|
|
55
84
|
* │ email │ is_target │
|
|
@@ -58,126 +87,212 @@ export declare class StringExprNamespace {
|
|
|
58
87
|
* │ admin@test.org │ true │
|
|
59
88
|
* └──────────────────┴───────────┘
|
|
60
89
|
*/
|
|
61
|
-
|
|
90
|
+
containsAny(patterns: (string | RegExp)[]): any;
|
|
62
91
|
/**
|
|
63
92
|
* Counts occurrences of a substring or regular expression match in each string element.
|
|
64
93
|
* @param pattern Search substring or regular expression.
|
|
65
94
|
* @returns ColumnExpression
|
|
66
95
|
* @example
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
96
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
97
|
+
* >>> df
|
|
98
|
+
* shape: (3, 1)
|
|
99
|
+
* ┌──────────┐
|
|
100
|
+
* │ s │
|
|
101
|
+
* ├──────────┤
|
|
102
|
+
* │ "apple" │
|
|
103
|
+
* │ "banana" │
|
|
104
|
+
* │ "cherry" │
|
|
105
|
+
* └──────────┘
|
|
106
|
+
* >>> df.withColumns($df.col("s").str.countMatches("a").alias("a_count"))
|
|
107
|
+
* shape: (3, 2)
|
|
108
|
+
* ┌──────────┬─────────┐
|
|
109
|
+
* │ s │ a_count │
|
|
110
|
+
* ├──────────┼─────────┤
|
|
111
|
+
* │ "apple" │ 1 │
|
|
112
|
+
* │ "banana" │ 3 │
|
|
113
|
+
* │ "cherry" │ 0 │
|
|
114
|
+
* └──────────┴─────────┘
|
|
115
|
+
*/
|
|
116
|
+
countMatches(pattern: string | RegExp | any, options?: {
|
|
78
117
|
literal?: boolean;
|
|
79
118
|
} | boolean): any;
|
|
80
119
|
/**
|
|
81
120
|
* Escapes special regular expression characters in string elements.
|
|
82
121
|
* @returns ColumnExpression
|
|
83
122
|
* @example
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
123
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
124
|
+
* >>> df
|
|
125
|
+
* shape: (3, 1)
|
|
126
|
+
* ┌──────────┐
|
|
127
|
+
* │ s │
|
|
128
|
+
* ├──────────┤
|
|
129
|
+
* │ "apple" │
|
|
130
|
+
* │ "banana" │
|
|
131
|
+
* │ "cherry" │
|
|
132
|
+
* └──────────┘
|
|
133
|
+
* >>> df.withColumns($df.col("s").str.escapeRegex().alias("escaped"))
|
|
134
|
+
* shape: (3, 2)
|
|
135
|
+
* ┌──────────┬─────────┐
|
|
136
|
+
* │ s │ escaped │
|
|
137
|
+
* ├──────────┼─────────┤
|
|
138
|
+
* │ "apple" │ apple │
|
|
139
|
+
* │ "banana" │ banana │
|
|
140
|
+
* │ "cherry" │ cherry │
|
|
141
|
+
* └──────────┴─────────┘
|
|
93
142
|
*/
|
|
94
|
-
|
|
143
|
+
escapeRegex(options?: EscapeRegexOptions): any;
|
|
95
144
|
/**
|
|
96
145
|
* Decodes hex or base64 encoded string column values into string.
|
|
146
|
+
* @note [Runtime Fallback]: Automatically leverages native `Uint8Array.fromBase64` / `Uint8Array.fromHex`
|
|
147
|
+
* when available in the runtime, with seamless automatic fallback to standard decoding across older environments.
|
|
97
148
|
* @param options Object containing encoding ("hex" | "base64") and optional strict flag
|
|
98
149
|
* @returns ColumnExpression
|
|
99
150
|
* @example
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
151
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
152
|
+
* >>> df
|
|
153
|
+
* shape: (3, 1)
|
|
154
|
+
* ┌──────────┐
|
|
155
|
+
* │ s │
|
|
156
|
+
* ├──────────┤
|
|
157
|
+
* │ "apple" │
|
|
158
|
+
* │ "banana" │
|
|
159
|
+
* │ "cherry" │
|
|
160
|
+
* └──────────┘
|
|
161
|
+
* >>> df.withColumns($df.col("s").str.encode({ encoding: "hex" }).str.decode({ encoding: "hex" }).alias("decoded"))
|
|
162
|
+
* shape: (3, 2)
|
|
163
|
+
* ┌──────────┬─────────┐
|
|
164
|
+
* │ s │ decoded │
|
|
165
|
+
* ├──────────┼─────────┤
|
|
166
|
+
* │ "apple" │ apple │
|
|
167
|
+
* │ "banana" │ banana │
|
|
168
|
+
* │ "cherry" │ cherry │
|
|
169
|
+
* └──────────┴─────────┘
|
|
108
170
|
*/
|
|
109
171
|
decode(options: StringDecodeOptions): any;
|
|
110
172
|
/**
|
|
111
173
|
* Encodes string column values into hex or base64.
|
|
174
|
+
* @note [Runtime Fallback]: Automatically leverages native `Uint8Array.prototype.toBase64` / `Uint8Array.prototype.toHex`
|
|
175
|
+
* when available, with automatic fallback across standard environments.
|
|
112
176
|
* @param options Object containing encoding ("hex" | "base64")
|
|
113
177
|
* @returns ColumnExpression
|
|
114
178
|
* @example
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
179
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
180
|
+
* >>> df
|
|
181
|
+
* shape: (3, 1)
|
|
182
|
+
* ┌──────────┐
|
|
183
|
+
* │ s │
|
|
184
|
+
* ├──────────┤
|
|
185
|
+
* │ "apple" │
|
|
186
|
+
* │ "banana" │
|
|
187
|
+
* │ "cherry" │
|
|
188
|
+
* └──────────┘
|
|
189
|
+
* >>> df.withColumns($df.col("s").str.encode({ encoding: "hex" }).alias("encoded"))
|
|
190
|
+
* shape: (3, 2)
|
|
191
|
+
* ┌──────────┬────────────────┐
|
|
192
|
+
* │ s │ encoded │
|
|
193
|
+
* ├──────────┼────────────────┤
|
|
194
|
+
* │ "apple" │ 6170706c65 │
|
|
195
|
+
* │ "banana" │ 62616e616e61 │
|
|
196
|
+
* │ "cherry" │ 636865727279 │
|
|
197
|
+
* └──────────┴────────────────┘
|
|
123
198
|
*/
|
|
124
199
|
encode(options: StringEncodeOptions): any;
|
|
125
200
|
/**
|
|
126
201
|
* Decodes Uniform Resource Identifier (URI) components.
|
|
127
202
|
* @returns ColumnExpression
|
|
128
203
|
* @example
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
204
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
205
|
+
* >>> df
|
|
206
|
+
* shape: (3, 1)
|
|
207
|
+
* ┌──────────┐
|
|
208
|
+
* │ s │
|
|
209
|
+
* ├──────────┤
|
|
210
|
+
* │ "apple" │
|
|
211
|
+
* │ "banana" │
|
|
212
|
+
* │ "cherry" │
|
|
213
|
+
* └──────────┘
|
|
214
|
+
* >>> df.withColumns($df.col("s").str.encodeUriComponent().str.decodeUriComponent().alias("decoded"))
|
|
215
|
+
* shape: (2, 2)
|
|
216
|
+
* ┌─────────────┬─────────────┐
|
|
217
|
+
* │ s │ decoded │
|
|
218
|
+
* ├─────────────┼─────────────┤
|
|
219
|
+
* │ " hello " │ " hello " │
|
|
220
|
+
* │ " world " │ " world " │
|
|
221
|
+
* └─────────────┴─────────────┘
|
|
137
222
|
*/
|
|
138
|
-
|
|
223
|
+
decodeUriComponent(): any;
|
|
139
224
|
/**
|
|
140
225
|
* Encodes Uniform Resource Identifier (URI) components.
|
|
141
226
|
* @returns ColumnExpression
|
|
142
227
|
* @example
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
228
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
229
|
+
* >>> df
|
|
230
|
+
* shape: (3, 1)
|
|
231
|
+
* ┌──────────┐
|
|
232
|
+
* │ s │
|
|
233
|
+
* ├──────────┤
|
|
234
|
+
* │ "apple" │
|
|
235
|
+
* │ "banana" │
|
|
236
|
+
* │ "cherry" │
|
|
237
|
+
* └──────────┘
|
|
238
|
+
* >>> df.withColumns($df.col("s").str.encodeUriComponent().alias("encoded"))
|
|
239
|
+
* shape: (2, 2)
|
|
240
|
+
* ┌─────────────┬───────────────────┐
|
|
241
|
+
* │ s │ encoded │
|
|
242
|
+
* ├─────────────┼───────────────────┤
|
|
243
|
+
* │ " hello " │ "%20%20hello%20%20" │
|
|
244
|
+
* │ " world " │ "%20%20world%20%20" │
|
|
245
|
+
* └─────────────┴───────────────────┘
|
|
151
246
|
*/
|
|
152
|
-
|
|
247
|
+
encodeUriComponent(): any;
|
|
153
248
|
/**
|
|
154
249
|
* Checks if string ends with a suffix.
|
|
155
250
|
* @param suffix The suffix substring.
|
|
156
251
|
* @returns ColumnExpression
|
|
157
252
|
* @example
|
|
158
|
-
|
|
159
|
-
|
|
253
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
254
|
+
* >>> df
|
|
255
|
+
* shape: (3, 1)
|
|
256
|
+
* ┌──────────┐
|
|
257
|
+
* │ s │
|
|
258
|
+
* ├──────────┤
|
|
259
|
+
* │ "apple" │
|
|
260
|
+
* │ "banana" │
|
|
261
|
+
* │ "cherry" │
|
|
262
|
+
* └──────────┘
|
|
263
|
+
* >>> df.withColumns($df.col("email").str.endsWith(".org").alias("is_org"))
|
|
160
264
|
* shape: (2, 2)
|
|
161
|
-
*
|
|
162
|
-
* │ email
|
|
163
|
-
*
|
|
164
|
-
* │ user@
|
|
165
|
-
* │ admin@
|
|
166
|
-
*
|
|
265
|
+
* ┌──────────────────┬────────┐
|
|
266
|
+
* │ email │ is_org │
|
|
267
|
+
* ├──────────────────┼────────┤
|
|
268
|
+
* │ user@example.com │ false │
|
|
269
|
+
* │ admin@test.org │ true │
|
|
270
|
+
* └──────────────────┴────────┘
|
|
167
271
|
*/
|
|
168
|
-
|
|
272
|
+
endsWith(suffix: string): any;
|
|
169
273
|
/**
|
|
170
274
|
* Splits strings into lists of single characters.
|
|
171
275
|
* @returns ColumnExpression
|
|
172
276
|
* @example
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
277
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
278
|
+
* >>> df
|
|
279
|
+
* shape: (3, 1)
|
|
280
|
+
* ┌──────────┐
|
|
281
|
+
* │ s │
|
|
282
|
+
* ├──────────┤
|
|
283
|
+
* │ "apple" │
|
|
284
|
+
* │ "banana" │
|
|
285
|
+
* │ "cherry" │
|
|
286
|
+
* └──────────┘
|
|
287
|
+
* >>> df.withColumns($df.col("s").str.explode().alias("chars"))
|
|
288
|
+
* shape: (3, 2)
|
|
289
|
+
* ┌──────────┬─────────────────────────────────────┐
|
|
290
|
+
* │ s │ chars │
|
|
291
|
+
* ├──────────┼─────────────────────────────────────┤
|
|
292
|
+
* │ "apple" │ ["a", "p", "p", "l", "e"] │
|
|
293
|
+
* │ "banana" │ ["b", "a", "n", "a", "n", "a"] │
|
|
294
|
+
* │ "cherry" │ ["c", "h", "e", "r", "r", "y"] │
|
|
295
|
+
* └──────────┴─────────────────────────────────────┘
|
|
181
296
|
*/
|
|
182
297
|
explode(): any;
|
|
183
298
|
/**
|
|
@@ -186,14 +301,24 @@ export declare class StringExprNamespace {
|
|
|
186
301
|
* @param options Options object. Use `groupIndex` to select the group (default 1).
|
|
187
302
|
* @returns ColumnExpression
|
|
188
303
|
* @example
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
304
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
305
|
+
* >>> df
|
|
306
|
+
* shape: (3, 1)
|
|
307
|
+
* ┌──────────┐
|
|
308
|
+
* │ s │
|
|
309
|
+
* ├──────────┤
|
|
310
|
+
* │ "apple" │
|
|
311
|
+
* │ "banana" │
|
|
312
|
+
* │ "cherry" │
|
|
313
|
+
* └──────────┘
|
|
314
|
+
* >>> df.withColumns($df.col("email").str.extract(/@(\w+)/).alias("domain"))
|
|
315
|
+
* shape: (2, 2)
|
|
316
|
+
* ┌──────────────────┬─────────┐
|
|
317
|
+
* │ email │ domain │
|
|
318
|
+
* ├──────────────────┼─────────┤
|
|
319
|
+
* │ user@example.com │ example │
|
|
320
|
+
* │ admin@test.org │ test │
|
|
321
|
+
* └──────────────────┴─────────┘
|
|
197
322
|
*/
|
|
198
323
|
extract(pattern: RegExp | string, options?: ExtractRegexEngineOptions): any;
|
|
199
324
|
/**
|
|
@@ -202,47 +327,79 @@ export declare class StringExprNamespace {
|
|
|
202
327
|
* @param options Options object. Use `groupIndex` to select the group (default 0).
|
|
203
328
|
* @returns ColumnExpression
|
|
204
329
|
* @example
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
330
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
331
|
+
* >>> df
|
|
332
|
+
* shape: (3, 1)
|
|
333
|
+
* ┌──────────┐
|
|
334
|
+
* │ s │
|
|
335
|
+
* ├──────────┤
|
|
336
|
+
* │ "apple" │
|
|
337
|
+
* │ "banana" │
|
|
338
|
+
* │ "cherry" │
|
|
339
|
+
* └──────────┘
|
|
340
|
+
* >>> df.withColumns($df.col("s").str.extractAll(/[aeiou]/).alias("vowels"))
|
|
341
|
+
* shape: (3, 2)
|
|
342
|
+
* ┌──────────┬─────────────────┐
|
|
343
|
+
* │ s │ vowels │
|
|
344
|
+
* ├──────────┼─────────────────┤
|
|
345
|
+
* │ "apple" │ ["a", "e"] │
|
|
346
|
+
* │ "banana" │ ["a", "a", "a"] │
|
|
347
|
+
* │ "cherry" │ ["e"] │
|
|
348
|
+
* └──────────┴─────────────────┘
|
|
213
349
|
*/
|
|
214
|
-
|
|
350
|
+
extractAll(pattern: string | RegExp, options?: ExtractRegexEngineOptions): any;
|
|
215
351
|
/**
|
|
216
352
|
* Extracts all captured groups from the first regex match into a structured object (struct).
|
|
217
353
|
* @param pattern Search pattern containing capture groups.
|
|
218
354
|
* @returns ColumnExpression
|
|
219
355
|
* @example
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
356
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
357
|
+
* >>> df
|
|
358
|
+
* shape: (3, 1)
|
|
359
|
+
* ┌──────────┐
|
|
360
|
+
* │ s │
|
|
361
|
+
* ├──────────┤
|
|
362
|
+
* │ "apple" │
|
|
363
|
+
* │ "banana" │
|
|
364
|
+
* │ "cherry" │
|
|
365
|
+
* └──────────┘
|
|
366
|
+
* >>> df.withColumns($df.col("email").str.extractGroups(/(?<user>\w+)@(?<domain>\w+)/).alias("parsed"))
|
|
367
|
+
* shape: (2, 2)
|
|
368
|
+
* ┌──────────────────┬────────────────────────────────────┐
|
|
369
|
+
* │ email │ parsed │
|
|
370
|
+
* ├──────────────────┼────────────────────────────────────┤
|
|
371
|
+
* │ user@example.com │ { user: "user", domain: "example" }│
|
|
372
|
+
* │ admin@test.org │ { user: "admin", domain: "test" } │
|
|
373
|
+
* └──────────────────┴────────────────────────────────────┘
|
|
228
374
|
*/
|
|
229
|
-
|
|
375
|
+
extractGroups(pattern: string | RegExp, options?: ExtractManyOptions): any;
|
|
230
376
|
/**
|
|
231
377
|
* Extracts the first regex match for each pattern in a list of patterns.
|
|
232
378
|
* @param patterns Array of regular expression patterns or strings.
|
|
233
379
|
* @param options Named options object ({ asciiCaseInsensitive, overlapping }).
|
|
234
380
|
* @returns ColumnExpression
|
|
235
381
|
* @example
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
382
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
383
|
+
* >>> df
|
|
384
|
+
* shape: (3, 1)
|
|
385
|
+
* ┌──────────┐
|
|
386
|
+
* │ s │
|
|
387
|
+
* ├──────────┤
|
|
388
|
+
* │ "apple" │
|
|
389
|
+
* │ "banana" │
|
|
390
|
+
* │ "cherry" │
|
|
391
|
+
* └──────────┘
|
|
392
|
+
* >>> df.withColumns($df.col("s").str.extractMany([/app/, /ban/, /che/]).alias("extracted"))
|
|
393
|
+
* shape: (3, 2)
|
|
394
|
+
* ┌──────────┬─────────────┐
|
|
395
|
+
* │ s │ extracted │
|
|
396
|
+
* ├──────────┼─────────────┤
|
|
397
|
+
* │ "apple" │ ["app"] │
|
|
398
|
+
* │ "banana" │ ["ban"] │
|
|
399
|
+
* │ "cherry" │ ["che"] │
|
|
400
|
+
* └──────────┴─────────────┘
|
|
244
401
|
*/
|
|
245
|
-
|
|
402
|
+
extractMany(patterns: (string | RegExp)[], options?: ExtractManyOptions): any;
|
|
246
403
|
/**
|
|
247
404
|
* Return the byte offset of the first substring matching a pattern.
|
|
248
405
|
* Returns null if pattern is not found.
|
|
@@ -250,14 +407,25 @@ export declare class StringExprNamespace {
|
|
|
250
407
|
* @param options Configuration options ({ literal, asciiCaseInsensitive }).
|
|
251
408
|
* @returns ColumnExpression
|
|
252
409
|
* @example
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
410
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
411
|
+
* >>> df
|
|
412
|
+
* shape: (3, 1)
|
|
413
|
+
* ┌──────────┐
|
|
414
|
+
* │ s │
|
|
415
|
+
* ├──────────┤
|
|
416
|
+
* │ "apple" │
|
|
417
|
+
* │ "banana" │
|
|
418
|
+
* │ "cherry" │
|
|
419
|
+
* └──────────┘
|
|
420
|
+
* >>> df.withColumns($df.col("s").str.find("a").alias("pos"))
|
|
421
|
+
* shape: (3, 2)
|
|
422
|
+
* ┌──────────┬──────┐
|
|
423
|
+
* │ s │ pos │
|
|
424
|
+
* ├──────────┼──────┤
|
|
425
|
+
* │ "apple" │ 0 │
|
|
426
|
+
* │ "banana" │ 1 │
|
|
427
|
+
* │ "cherry" │ null │
|
|
428
|
+
* └──────────┴──────┘
|
|
261
429
|
*/
|
|
262
430
|
find(value: string | RegExp, options?: FindOptions): any;
|
|
263
431
|
/**
|
|
@@ -266,30 +434,51 @@ export declare class StringExprNamespace {
|
|
|
266
434
|
* @param options Configuration options ({ literal, asciiCaseInsensitive, overlapping, leftmost }).
|
|
267
435
|
* @returns ColumnExpression
|
|
268
436
|
* @example
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
437
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
438
|
+
* >>> df
|
|
439
|
+
* shape: (3, 1)
|
|
440
|
+
* ┌──────────┐
|
|
441
|
+
* │ s │
|
|
442
|
+
* ├──────────┤
|
|
443
|
+
* │ "apple" │
|
|
444
|
+
* │ "banana" │
|
|
445
|
+
* │ "cherry" │
|
|
446
|
+
* └──────────┘
|
|
447
|
+
* >>> df.withColumns($df.col("s").str.findMany(["a", "e"]).alias("positions"))
|
|
448
|
+
* shape: (3, 2)
|
|
449
|
+
* ┌──────────┬───────────┐
|
|
450
|
+
* │ s │ positions │
|
|
451
|
+
* ├──────────┼───────────┤
|
|
452
|
+
* │ "apple" │ [0, 4] │
|
|
453
|
+
* │ "banana" │ [1] │
|
|
454
|
+
* │ "cherry" │ [2] │
|
|
455
|
+
* └──────────┴───────────┘
|
|
277
456
|
*/
|
|
278
|
-
|
|
457
|
+
findMany(patterns: (string | RegExp)[], options?: FindManyOptions): any;
|
|
279
458
|
/**
|
|
280
459
|
* Extracts the first n characters of each string element.
|
|
281
460
|
* @param n Number of characters to extract from the start of the string (default 1).
|
|
282
461
|
* @returns ColumnExpression
|
|
283
462
|
* @example
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
463
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
464
|
+
* >>> df
|
|
465
|
+
* shape: (3, 1)
|
|
466
|
+
* ┌──────────┐
|
|
467
|
+
* │ s │
|
|
468
|
+
* ├──────────┤
|
|
469
|
+
* │ "apple" │
|
|
470
|
+
* │ "banana" │
|
|
471
|
+
* │ "cherry" │
|
|
472
|
+
* └──────────┘
|
|
473
|
+
* >>> df.withColumns($df.col("s").str.head(3).alias("prefix"))
|
|
474
|
+
* shape: (3, 2)
|
|
475
|
+
* ┌──────────┬────────┐
|
|
476
|
+
* │ s │ prefix │
|
|
477
|
+
* ├──────────┼────────┤
|
|
478
|
+
* │ "apple" │ app │
|
|
479
|
+
* │ "banana" │ ban │
|
|
480
|
+
* │ "cherry" │ che │
|
|
481
|
+
* └──────────┴────────┘
|
|
293
482
|
*/
|
|
294
483
|
head(n?: number): any;
|
|
295
484
|
/**
|
|
@@ -299,15 +488,23 @@ export declare class StringExprNamespace {
|
|
|
299
488
|
* @param options Formatting configuration options (`JoinArrayOptions`).
|
|
300
489
|
* @returns ColumnExpression
|
|
301
490
|
* @example
|
|
302
|
-
|
|
303
|
-
|
|
491
|
+
* >>> const df = $df.data({ a: [[1, 2, 3], [4, 5]] })
|
|
492
|
+
* >>> df
|
|
493
|
+
* shape: (2, 1)
|
|
494
|
+
* ┌───────────┐
|
|
495
|
+
* │ a │
|
|
496
|
+
* ├───────────┤
|
|
497
|
+
* │ [1, 2, 3] │
|
|
498
|
+
* │ [4, 5] │
|
|
499
|
+
* └───────────┘
|
|
500
|
+
* >>> df.withColumns($df.col("a").str.join("-").alias("joined"))
|
|
304
501
|
* shape: (2, 2)
|
|
305
|
-
*
|
|
306
|
-
* │
|
|
307
|
-
*
|
|
308
|
-
* │ ["a", "b"
|
|
309
|
-
* │ ["
|
|
310
|
-
*
|
|
502
|
+
* ┌────────────┬────────┐
|
|
503
|
+
* │ a │ joined │
|
|
504
|
+
* ├────────────┼────────┤
|
|
505
|
+
* │ ["a", "b"] │ a-b │
|
|
506
|
+
* │ ["c"] │ c │
|
|
507
|
+
* └────────────┴────────┘
|
|
311
508
|
*/
|
|
312
509
|
join(delimiter?: string, options?: JoinArrayOptions): any;
|
|
313
510
|
/**
|
|
@@ -316,87 +513,149 @@ export declare class StringExprNamespace {
|
|
|
316
513
|
* @param options Configuration options for parsing (`SafeJsonParseOptions`).
|
|
317
514
|
* @returns ColumnExpression
|
|
318
515
|
* @example
|
|
319
|
-
|
|
320
|
-
|
|
516
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
517
|
+
* >>> df
|
|
518
|
+
* shape: (3, 1)
|
|
519
|
+
* ┌──────────┐
|
|
520
|
+
* │ s │
|
|
521
|
+
* ├──────────┤
|
|
522
|
+
* │ "apple" │
|
|
523
|
+
* │ "banana" │
|
|
524
|
+
* │ "cherry" │
|
|
525
|
+
* └──────────┘
|
|
526
|
+
* >>> df.withColumns($df.col("s").str.trim().str.jsonDecode().alias("parsed"))
|
|
321
527
|
* shape: (2, 2)
|
|
322
|
-
*
|
|
323
|
-
* │
|
|
324
|
-
*
|
|
325
|
-
* │
|
|
326
|
-
* │
|
|
327
|
-
*
|
|
528
|
+
* ┌─────────────┬─────────┐
|
|
529
|
+
* │ s │ parsed │
|
|
530
|
+
* ├─────────────┼─────────┤
|
|
531
|
+
* │ " hello " │ "hello" │
|
|
532
|
+
* │ " world " │ "world" │
|
|
533
|
+
* └─────────────┴─────────┘
|
|
328
534
|
*/
|
|
329
|
-
|
|
535
|
+
jsonDecode(options?: SafeJsonParseOptions): any;
|
|
330
536
|
/**
|
|
331
537
|
* Extracts fields or array elements from JSON strings using JSONPath syntax.
|
|
332
538
|
* @param jsonPath The JSONPath expression (e.g. `"$.store.book[0].title"` or `"$.a.b"`).
|
|
333
539
|
* @returns ColumnExpression
|
|
334
540
|
* @example
|
|
335
|
-
|
|
336
|
-
|
|
541
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
542
|
+
* >>> df
|
|
543
|
+
* shape: (3, 1)
|
|
544
|
+
* ┌──────────┐
|
|
545
|
+
* │ s │
|
|
546
|
+
* ├──────────┤
|
|
547
|
+
* │ "apple" │
|
|
548
|
+
* │ "banana" │
|
|
549
|
+
* │ "cherry" │
|
|
550
|
+
* └──────────┘
|
|
551
|
+
* >>> df.withColumns($df.col("s").str.trim().str.jsonPathMatch("$").alias("val"))
|
|
337
552
|
* shape: (2, 2)
|
|
338
|
-
*
|
|
339
|
-
* │
|
|
340
|
-
*
|
|
341
|
-
* │
|
|
342
|
-
* │
|
|
343
|
-
*
|
|
553
|
+
* ┌─────────────┬─────────┐
|
|
554
|
+
* │ s │ val │
|
|
555
|
+
* ├─────────────┼─────────┤
|
|
556
|
+
* │ " hello " │ "hello" │
|
|
557
|
+
* │ " world " │ "world" │
|
|
558
|
+
* └─────────────┴─────────┘
|
|
344
559
|
*/
|
|
345
|
-
|
|
560
|
+
jsonPathMatch(jsonPath: string): any;
|
|
346
561
|
/**
|
|
347
|
-
* Returns string length in UTF-16 code units. Alias for
|
|
562
|
+
* Returns string length in UTF-16 code units. Alias for lenChars.
|
|
348
563
|
* @returns ColumnExpression
|
|
349
564
|
* @example
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
565
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
566
|
+
* >>> df
|
|
567
|
+
* shape: (3, 1)
|
|
568
|
+
* ┌──────────┐
|
|
569
|
+
* │ s │
|
|
570
|
+
* ├──────────┤
|
|
571
|
+
* │ "apple" │
|
|
572
|
+
* │ "banana" │
|
|
573
|
+
* │ "cherry" │
|
|
574
|
+
* └──────────┘
|
|
575
|
+
* >>> df.withColumns($df.col("s").str.len().alias("length"))
|
|
576
|
+
* shape: (3, 2)
|
|
577
|
+
* ┌──────────┬────────┐
|
|
578
|
+
* │ s │ length │
|
|
579
|
+
* ├──────────┼────────┤
|
|
580
|
+
* │ "apple" │ 5 │
|
|
581
|
+
* │ "banana" │ 6 │
|
|
582
|
+
* │ "cherry" │ 6 │
|
|
583
|
+
* └──────────┴────────┘
|
|
358
584
|
*/
|
|
359
585
|
len(): any;
|
|
360
586
|
/**
|
|
361
587
|
* Returns string length in UTF-8 encoded bytes.
|
|
362
588
|
* @returns ColumnExpression
|
|
363
589
|
* @example
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
590
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
591
|
+
* >>> df
|
|
592
|
+
* shape: (3, 1)
|
|
593
|
+
* ┌──────────┐
|
|
594
|
+
* │ s │
|
|
595
|
+
* ├──────────┤
|
|
596
|
+
* │ "apple" │
|
|
597
|
+
* │ "banana" │
|
|
598
|
+
* │ "cherry" │
|
|
599
|
+
* └──────────┘
|
|
600
|
+
* >>> df.withColumns($df.col("s").str.lenBytes().alias("bytes"))
|
|
601
|
+
* shape: (3, 2)
|
|
602
|
+
* ┌──────────┬───────┐
|
|
603
|
+
* │ s │ bytes │
|
|
604
|
+
* ├──────────┼───────┤
|
|
605
|
+
* │ "apple" │ 5 │
|
|
606
|
+
* │ "banana" │ 6 │
|
|
607
|
+
* │ "cherry" │ 6 │
|
|
608
|
+
* └──────────┴───────┘
|
|
372
609
|
*/
|
|
373
|
-
|
|
610
|
+
lenBytes(): any;
|
|
374
611
|
/**
|
|
375
612
|
* Returns string length in character count.
|
|
376
613
|
* @returns ColumnExpression
|
|
377
614
|
* @example
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
615
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
616
|
+
* >>> df
|
|
617
|
+
* shape: (3, 1)
|
|
618
|
+
* ┌──────────┐
|
|
619
|
+
* │ s │
|
|
620
|
+
* ├──────────┤
|
|
621
|
+
* │ "apple" │
|
|
622
|
+
* │ "banana" │
|
|
623
|
+
* │ "cherry" │
|
|
624
|
+
* └──────────┘
|
|
625
|
+
* >>> df.withColumns($df.col("s").str.lenChars().alias("length"))
|
|
626
|
+
* shape: (3, 2)
|
|
627
|
+
* ┌──────────┬────────┐
|
|
628
|
+
* │ s │ length │
|
|
629
|
+
* ├──────────┼────────┤
|
|
630
|
+
* │ "apple" │ 5 │
|
|
631
|
+
* │ "banana" │ 6 │
|
|
632
|
+
* │ "cherry" │ 6 │
|
|
633
|
+
* └──────────┴────────┘
|
|
386
634
|
*/
|
|
387
|
-
|
|
635
|
+
lenChars(): any;
|
|
388
636
|
/**
|
|
389
637
|
* Converts strings to lowercase.
|
|
390
638
|
* @returns ColumnExpression
|
|
391
639
|
* @example
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
640
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
641
|
+
* >>> df
|
|
642
|
+
* shape: (3, 1)
|
|
643
|
+
* ┌──────────┐
|
|
644
|
+
* │ s │
|
|
645
|
+
* ├──────────┤
|
|
646
|
+
* │ "apple" │
|
|
647
|
+
* │ "banana" │
|
|
648
|
+
* │ "cherry" │
|
|
649
|
+
* └──────────┘
|
|
650
|
+
* >>> df.withColumns($df.col("s").str.lower().alias("lowered"))
|
|
651
|
+
* shape: (3, 2)
|
|
652
|
+
* ┌─────────────┬───────────┐
|
|
653
|
+
* │ s │ lowered │
|
|
654
|
+
* ├─────────────┼───────────┤
|
|
655
|
+
* │ "HELLO" │ hello │
|
|
656
|
+
* │ "World" │ world │
|
|
657
|
+
* │ "df-script" │ df-script │
|
|
658
|
+
* └─────────────┴───────────┘
|
|
400
659
|
*/
|
|
401
660
|
lower(): any;
|
|
402
661
|
/**
|
|
@@ -405,14 +664,25 @@ export declare class StringExprNamespace {
|
|
|
405
664
|
* @param fill Character sequence used for padding.
|
|
406
665
|
* @returns ColumnExpression
|
|
407
666
|
* @example
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
667
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
668
|
+
* >>> df
|
|
669
|
+
* shape: (3, 1)
|
|
670
|
+
* ┌──────────┐
|
|
671
|
+
* │ s │
|
|
672
|
+
* ├──────────┤
|
|
673
|
+
* │ "apple" │
|
|
674
|
+
* │ "banana" │
|
|
675
|
+
* │ "cherry" │
|
|
676
|
+
* └──────────┘
|
|
677
|
+
* >>> df.withColumns($df.col("s").str.lpad(8, "_").alias("padded"))
|
|
678
|
+
* shape: (3, 2)
|
|
679
|
+
* ┌──────────┬──────────┐
|
|
680
|
+
* │ s │ padded │
|
|
681
|
+
* ├──────────┼──────────┤
|
|
682
|
+
* │ "apple" │ ___apple │
|
|
683
|
+
* │ "banana" │ __banana │
|
|
684
|
+
* │ "cherry" │ __cherry │
|
|
685
|
+
* └──────────┴──────────┘
|
|
416
686
|
*/
|
|
417
687
|
lpad(width: number, fill?: string): any;
|
|
418
688
|
/**
|
|
@@ -421,14 +691,25 @@ export declare class StringExprNamespace {
|
|
|
421
691
|
* @returns ColumnExpression
|
|
422
692
|
* @throws InvalidArgumentError If an invalid normalization form is provided.
|
|
423
693
|
* @example
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
694
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
695
|
+
* >>> df
|
|
696
|
+
* shape: (3, 1)
|
|
697
|
+
* ┌──────────┐
|
|
698
|
+
* │ s │
|
|
699
|
+
* ├──────────┤
|
|
700
|
+
* │ "apple" │
|
|
701
|
+
* │ "banana" │
|
|
702
|
+
* │ "cherry" │
|
|
703
|
+
* └──────────┘
|
|
704
|
+
* >>> df.withColumns($df.col("s").str.normalize("NFC").alias("normalized"))
|
|
705
|
+
* shape: (3, 2)
|
|
706
|
+
* ┌─────────────┬────────────┐
|
|
707
|
+
* │ s │ normalized │
|
|
708
|
+
* ├─────────────┼────────────┤
|
|
709
|
+
* │ "HELLO" │ HELLO │
|
|
710
|
+
* │ "World" │ World │
|
|
711
|
+
* │ "df-script" │ df-script │
|
|
712
|
+
* └─────────────┴────────────┘
|
|
432
713
|
*/
|
|
433
714
|
normalize(form?: Parameters<typeof String.prototype.normalize>[0]): any;
|
|
434
715
|
/**
|
|
@@ -437,32 +718,54 @@ export declare class StringExprNamespace {
|
|
|
437
718
|
* @param fill Character sequence used for padding.
|
|
438
719
|
* @returns ColumnExpression
|
|
439
720
|
* @example
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
721
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
722
|
+
* >>> df
|
|
723
|
+
* shape: (3, 1)
|
|
724
|
+
* ┌──────────┐
|
|
725
|
+
* │ s │
|
|
726
|
+
* ├──────────┤
|
|
727
|
+
* │ "apple" │
|
|
728
|
+
* │ "banana" │
|
|
729
|
+
* │ "cherry" │
|
|
730
|
+
* └──────────┘
|
|
731
|
+
* >>> df.withColumns($df.col("s").str.padEnd(8, "_").alias("padded"))
|
|
732
|
+
* shape: (3, 2)
|
|
733
|
+
* ┌──────────┬──────────┐
|
|
734
|
+
* │ s │ padded │
|
|
735
|
+
* ├──────────┼──────────┤
|
|
736
|
+
* │ "apple" │ apple___ │
|
|
737
|
+
* │ "banana" │ banana__ │
|
|
738
|
+
* │ "cherry" │ cherry__ │
|
|
739
|
+
* └──────────┴──────────┘
|
|
448
740
|
*/
|
|
449
|
-
|
|
741
|
+
padEnd(width: number, fill?: string): any;
|
|
450
742
|
/**
|
|
451
743
|
* Pads start of strings to specified width. Alias for lpad.
|
|
452
744
|
* @param width Target string length.
|
|
453
745
|
* @param fill Character sequence used for padding.
|
|
454
746
|
* @returns ColumnExpression
|
|
455
747
|
* @example
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
748
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
749
|
+
* >>> df
|
|
750
|
+
* shape: (3, 1)
|
|
751
|
+
* ┌──────────┐
|
|
752
|
+
* │ s │
|
|
753
|
+
* ├──────────┤
|
|
754
|
+
* │ "apple" │
|
|
755
|
+
* │ "banana" │
|
|
756
|
+
* │ "cherry" │
|
|
757
|
+
* └──────────┘
|
|
758
|
+
* >>> df.withColumns($df.col("s").str.padStart(8, "_").alias("padded"))
|
|
759
|
+
* shape: (3, 2)
|
|
760
|
+
* ┌──────────┬──────────┐
|
|
761
|
+
* │ s │ padded │
|
|
762
|
+
* ├──────────┼──────────┤
|
|
763
|
+
* │ "apple" │ ___apple │
|
|
764
|
+
* │ "banana" │ __banana │
|
|
765
|
+
* │ "cherry" │ __cherry │
|
|
766
|
+
* └──────────┴──────────┘
|
|
464
767
|
*/
|
|
465
|
-
|
|
768
|
+
padStart(width: number, fill?: string): any;
|
|
466
769
|
/**
|
|
467
770
|
* Replaces the first occurrence matching a string pattern.
|
|
468
771
|
* @param pattern The search pattern string or regular expression.
|
|
@@ -470,14 +773,24 @@ export declare class StringExprNamespace {
|
|
|
470
773
|
* @param options Optional replace options (literal, asciiCaseInsensitive, n).
|
|
471
774
|
* @returns ColumnExpression
|
|
472
775
|
* @example
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
776
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
777
|
+
* >>> df
|
|
778
|
+
* shape: (3, 1)
|
|
779
|
+
* ┌──────────┐
|
|
780
|
+
* │ s │
|
|
781
|
+
* ├──────────┤
|
|
782
|
+
* │ "apple" │
|
|
783
|
+
* │ "banana" │
|
|
784
|
+
* │ "cherry" │
|
|
785
|
+
* └──────────┘
|
|
786
|
+
* >>> df.withColumns($df.col("email").str.replace("example", "test").alias("updated"))
|
|
787
|
+
* shape: (2, 2)
|
|
788
|
+
* ┌──────────────────┬───────────────┐
|
|
789
|
+
* │ email │ updated │
|
|
790
|
+
* ├──────────────────┼───────────────┤
|
|
791
|
+
* │ user@example.com │ user@test.com │
|
|
792
|
+
* │ admin@test.org │ admin@test.org│
|
|
793
|
+
* └──────────────────┴───────────────┘
|
|
481
794
|
*/
|
|
482
795
|
replace(pattern: string | RegExp, replacement: string | ((match: string, ...args: any[]) => string), options?: ReplaceOptions): any;
|
|
483
796
|
/**
|
|
@@ -487,46 +800,79 @@ export declare class StringExprNamespace {
|
|
|
487
800
|
* @param options Optional replace options (literal, asciiCaseInsensitive).
|
|
488
801
|
* @returns ColumnExpression
|
|
489
802
|
* @example
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
803
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
804
|
+
* >>> df
|
|
805
|
+
* shape: (3, 1)
|
|
806
|
+
* ┌──────────┐
|
|
807
|
+
* │ s │
|
|
808
|
+
* ├──────────┤
|
|
809
|
+
* │ "apple" │
|
|
810
|
+
* │ "banana" │
|
|
811
|
+
* │ "cherry" │
|
|
812
|
+
* └──────────┘
|
|
813
|
+
* >>> df.withColumns($df.col("s").str.replaceAll("a", "@").alias("replaced"))
|
|
814
|
+
* shape: (3, 2)
|
|
815
|
+
* ┌──────────┬──────────┐
|
|
816
|
+
* │ s │ replaced │
|
|
817
|
+
* ├──────────┼──────────┤
|
|
818
|
+
* │ "apple" │ @pple │
|
|
819
|
+
* │ "banana" │ b@n@n@ │
|
|
820
|
+
* │ "cherry" │ cherry │
|
|
821
|
+
* └──────────┴──────────┘
|
|
498
822
|
*/
|
|
499
|
-
|
|
823
|
+
replaceAll(pattern: string | RegExp, replacement: string | ((match: string, ...args: any[]) => string), options?: Omit<ReplaceOptions, "n">): any;
|
|
500
824
|
/**
|
|
501
825
|
* Replaces multiple string patterns simultaneously or sequentially with their respective replacements.
|
|
502
|
-
* Matches Polars `.str.
|
|
826
|
+
* Matches Polars `.str.replaceMany()` behavior, accepting pattern/replacement arrays or a pattern-to-replacement map dictionary.
|
|
503
827
|
* @param patterns Array of patterns or an object mapping target patterns to replacements.
|
|
504
828
|
* @param replacements Array of replacement strings/callbacks (when patterns is an array).
|
|
505
829
|
* @param options Configuration options ({ literal, asciiCaseInsensitive, mode }).
|
|
506
830
|
* @returns ColumnExpression
|
|
507
831
|
* @example
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
832
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
833
|
+
* >>> df
|
|
834
|
+
* shape: (3, 1)
|
|
835
|
+
* ┌──────────┐
|
|
836
|
+
* │ s │
|
|
837
|
+
* ├──────────┤
|
|
838
|
+
* │ "apple" │
|
|
839
|
+
* │ "banana" │
|
|
840
|
+
* │ "cherry" │
|
|
841
|
+
* └──────────┘
|
|
842
|
+
* >>> df.withColumns($df.col("s").str.replaceMany(["apple", "banana"], ["1", "2"]).alias("res"))
|
|
843
|
+
* shape: (3, 2)
|
|
844
|
+
* ┌──────────┬────────┐
|
|
845
|
+
* │ s │ res │
|
|
846
|
+
* ├──────────┼────────┤
|
|
847
|
+
* │ "apple" │ 1 │
|
|
848
|
+
* │ "banana" │ 2 │
|
|
849
|
+
* │ "cherry" │ cherry │
|
|
850
|
+
* └──────────┴────────┘
|
|
516
851
|
*/
|
|
517
|
-
|
|
852
|
+
replaceMany(patterns: (string | RegExp)[] | Record<string, string>, replacements?: (string | ((match: string, ...args: any[]) => string))[], options?: ReplaceManyOptions): any;
|
|
518
853
|
/**
|
|
519
854
|
* Reverses characters in each string element.
|
|
520
855
|
* @returns ColumnExpression
|
|
521
856
|
* @example
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
857
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
858
|
+
* >>> df
|
|
859
|
+
* shape: (3, 1)
|
|
860
|
+
* ┌──────────┐
|
|
861
|
+
* │ s │
|
|
862
|
+
* ├──────────┤
|
|
863
|
+
* │ "apple" │
|
|
864
|
+
* │ "banana" │
|
|
865
|
+
* │ "cherry" │
|
|
866
|
+
* └──────────┘
|
|
867
|
+
* >>> df.withColumns($df.col("s").str.reverse().alias("rev"))
|
|
868
|
+
* shape: (3, 2)
|
|
869
|
+
* ┌──────────┬────────┐
|
|
870
|
+
* │ s │ rev │
|
|
871
|
+
* ├──────────┼────────┤
|
|
872
|
+
* │ "apple" │ elppa │
|
|
873
|
+
* │ "banana" │ ananab │
|
|
874
|
+
* │ "cherry" │ yrrehc │
|
|
875
|
+
* └──────────┴────────┘
|
|
530
876
|
*/
|
|
531
877
|
reverse(): any;
|
|
532
878
|
/**
|
|
@@ -535,14 +881,25 @@ export declare class StringExprNamespace {
|
|
|
535
881
|
* @param fill Character sequence used for padding.
|
|
536
882
|
* @returns ColumnExpression
|
|
537
883
|
* @example
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
884
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
885
|
+
* >>> df
|
|
886
|
+
* shape: (3, 1)
|
|
887
|
+
* ┌──────────┐
|
|
888
|
+
* │ s │
|
|
889
|
+
* ├──────────┤
|
|
890
|
+
* │ "apple" │
|
|
891
|
+
* │ "banana" │
|
|
892
|
+
* │ "cherry" │
|
|
893
|
+
* └──────────┘
|
|
894
|
+
* >>> df.withColumns($df.col("s").str.rpad(8, "_").alias("padded"))
|
|
895
|
+
* shape: (3, 2)
|
|
896
|
+
* ┌──────────┬──────────┐
|
|
897
|
+
* │ s │ padded │
|
|
898
|
+
* ├──────────┼──────────┤
|
|
899
|
+
* │ "apple" │ apple___ │
|
|
900
|
+
* │ "banana" │ banana__ │
|
|
901
|
+
* │ "cherry" │ cherry__ │
|
|
902
|
+
* └──────────┴──────────┘
|
|
546
903
|
*/
|
|
547
904
|
rpad(width: number, fill?: string): any;
|
|
548
905
|
/**
|
|
@@ -551,14 +908,25 @@ export declare class StringExprNamespace {
|
|
|
551
908
|
* @param length Number of characters to include.
|
|
552
909
|
* @returns ColumnExpression
|
|
553
910
|
* @example
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
911
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
912
|
+
* >>> df
|
|
913
|
+
* shape: (3, 1)
|
|
914
|
+
* ┌──────────┐
|
|
915
|
+
* │ s │
|
|
916
|
+
* ├──────────┤
|
|
917
|
+
* │ "apple" │
|
|
918
|
+
* │ "banana" │
|
|
919
|
+
* │ "cherry" │
|
|
920
|
+
* └──────────┘
|
|
921
|
+
* >>> df.withColumns($df.col("s").str.slice(0, 3).alias("sub"))
|
|
922
|
+
* shape: (3, 2)
|
|
923
|
+
* ┌──────────┬─────┐
|
|
924
|
+
* │ s │ sub │
|
|
925
|
+
* ├──────────┼─────┤
|
|
926
|
+
* │ "apple" │ app │
|
|
927
|
+
* │ "banana" │ ban │
|
|
928
|
+
* │ "cherry" │ che │
|
|
929
|
+
* └──────────┴─────┘
|
|
562
930
|
*/
|
|
563
931
|
slice(offset: number, length?: number): any;
|
|
564
932
|
/**
|
|
@@ -567,14 +935,24 @@ export declare class StringExprNamespace {
|
|
|
567
935
|
* @param options Options for controlling limit and exact padding.
|
|
568
936
|
* @returns ColumnExpression
|
|
569
937
|
* @example
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
938
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
939
|
+
* >>> df
|
|
940
|
+
* shape: (3, 1)
|
|
941
|
+
* ┌──────────┐
|
|
942
|
+
* │ s │
|
|
943
|
+
* ├──────────┤
|
|
944
|
+
* │ "apple" │
|
|
945
|
+
* │ "banana" │
|
|
946
|
+
* │ "cherry" │
|
|
947
|
+
* └──────────┘
|
|
948
|
+
* >>> df.withColumns($df.col("email").str.split("@").alias("parts"))
|
|
949
|
+
* shape: (2, 2)
|
|
950
|
+
* ┌──────────────────┬────────────────────────┐
|
|
951
|
+
* │ email │ parts │
|
|
952
|
+
* ├──────────────────┼────────────────────────┤
|
|
953
|
+
* │ user@example.com │ ["user", "example.com"]│
|
|
954
|
+
* │ admin@test.org │ ["admin", "test.org"] │
|
|
955
|
+
* └──────────────────┴────────────────────────┘
|
|
578
956
|
*/
|
|
579
957
|
split(delimiter: string, options?: SplitOptions): any;
|
|
580
958
|
/**
|
|
@@ -582,118 +960,198 @@ export declare class StringExprNamespace {
|
|
|
582
960
|
* @param prefix The prefix substring.
|
|
583
961
|
* @returns ColumnExpression
|
|
584
962
|
* @example
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
963
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
964
|
+
* >>> df
|
|
965
|
+
* shape: (3, 1)
|
|
966
|
+
* ┌──────────┐
|
|
967
|
+
* │ s │
|
|
968
|
+
* ├──────────┤
|
|
969
|
+
* │ "apple" │
|
|
970
|
+
* │ "banana" │
|
|
971
|
+
* │ "cherry" │
|
|
972
|
+
* └──────────┘
|
|
973
|
+
* >>> df.withColumns($df.col("s").str.startsWith("a").alias("starts_a"))
|
|
974
|
+
* shape: (3, 2)
|
|
975
|
+
* ┌──────────┬──────────┐
|
|
976
|
+
* │ s │ starts_a │
|
|
977
|
+
* ├──────────┼──────────┤
|
|
978
|
+
* │ "apple" │ true │
|
|
979
|
+
* │ "banana" │ false │
|
|
980
|
+
* │ "cherry" │ false │
|
|
981
|
+
* └──────────┴──────────┘
|
|
594
982
|
*/
|
|
595
|
-
|
|
983
|
+
startsWith(prefix: string): any;
|
|
596
984
|
/**
|
|
597
985
|
* Strips matching characters from start and end of string.
|
|
598
986
|
* @param characters Characters or regex pattern to strip.
|
|
599
987
|
* @param options Configuration options for strip operation.
|
|
600
988
|
* @returns ColumnExpression
|
|
601
989
|
* @example
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
990
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
991
|
+
* >>> df
|
|
992
|
+
* shape: (3, 1)
|
|
993
|
+
* ┌──────────┐
|
|
994
|
+
* │ s │
|
|
995
|
+
* ├──────────┤
|
|
996
|
+
* │ "apple" │
|
|
997
|
+
* │ "banana" │
|
|
998
|
+
* │ "cherry" │
|
|
999
|
+
* └──────────┘
|
|
1000
|
+
* >>> df.withColumns($df.col("s").str.stripChars().alias("stripped"))
|
|
1001
|
+
* shape: (2, 2)
|
|
1002
|
+
* ┌─────────────┬──────────┐
|
|
1003
|
+
* │ s │ stripped │
|
|
1004
|
+
* ├─────────────┼──────────┤
|
|
1005
|
+
* │ " hello " │ hello │
|
|
1006
|
+
* │ " world " │ world │
|
|
1007
|
+
* └─────────────┴──────────┘
|
|
610
1008
|
*/
|
|
611
|
-
|
|
1009
|
+
stripChars(characters?: string | RegExp, options?: StripCharsOptions): any;
|
|
612
1010
|
/**
|
|
613
1011
|
* Strips matching characters from end of string.
|
|
614
1012
|
* @param characters Characters or regex pattern to strip.
|
|
615
1013
|
* @param options Configuration options.
|
|
616
1014
|
* @returns ColumnExpression
|
|
617
1015
|
* @example
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
1016
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
1017
|
+
* >>> df
|
|
1018
|
+
* shape: (3, 1)
|
|
1019
|
+
* ┌──────────┐
|
|
1020
|
+
* │ s │
|
|
1021
|
+
* ├──────────┤
|
|
1022
|
+
* │ "apple" │
|
|
1023
|
+
* │ "banana" │
|
|
1024
|
+
* │ "cherry" │
|
|
1025
|
+
* └──────────┘
|
|
1026
|
+
* >>> df.withColumns($df.col("s").str.stripCharsEnd().alias("stripped"))
|
|
1027
|
+
* shape: (2, 2)
|
|
1028
|
+
* ┌─────────────┬──────────┐
|
|
1029
|
+
* │ s │ stripped │
|
|
1030
|
+
* ├─────────────┼──────────┤
|
|
1031
|
+
* │ " hello " │ " hello" │
|
|
1032
|
+
* │ " world " │ " world" │
|
|
1033
|
+
* └─────────────┴──────────┘
|
|
626
1034
|
*/
|
|
627
|
-
|
|
1035
|
+
stripCharsEnd(characters?: string | RegExp, options?: StripCharsOptions): any;
|
|
628
1036
|
/**
|
|
629
1037
|
* Strips matching characters from start of string.
|
|
630
1038
|
* @param characters Characters or regex pattern to strip.
|
|
631
1039
|
* @param options Configuration options.
|
|
632
1040
|
* @returns ColumnExpression
|
|
633
1041
|
* @example
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
1042
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
1043
|
+
* >>> df
|
|
1044
|
+
* shape: (3, 1)
|
|
1045
|
+
* ┌──────────┐
|
|
1046
|
+
* │ s │
|
|
1047
|
+
* ├──────────┤
|
|
1048
|
+
* │ "apple" │
|
|
1049
|
+
* │ "banana" │
|
|
1050
|
+
* │ "cherry" │
|
|
1051
|
+
* └──────────┘
|
|
1052
|
+
* >>> df.withColumns($df.col("s").str.stripCharsStart().alias("stripped"))
|
|
1053
|
+
* shape: (2, 2)
|
|
1054
|
+
* ┌─────────────┬──────────┐
|
|
1055
|
+
* │ s │ stripped │
|
|
1056
|
+
* ├─────────────┼──────────┤
|
|
1057
|
+
* │ " hello " │ "hello " │
|
|
1058
|
+
* │ " world " │ "world " │
|
|
1059
|
+
* └─────────────┴──────────┘
|
|
642
1060
|
*/
|
|
643
|
-
|
|
1061
|
+
stripCharsStart(characters?: string | RegExp, options?: StripCharsOptions): any;
|
|
644
1062
|
/**
|
|
645
1063
|
* Strips matching prefix substring from start of string.
|
|
646
1064
|
* @param prefix Prefix substring to remove.
|
|
647
1065
|
* @returns ColumnExpression
|
|
648
1066
|
* @example
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
1067
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
1068
|
+
* >>> df
|
|
1069
|
+
* shape: (3, 1)
|
|
1070
|
+
* ┌──────────┐
|
|
1071
|
+
* │ s │
|
|
1072
|
+
* ├──────────┤
|
|
1073
|
+
* │ "apple" │
|
|
1074
|
+
* │ "banana" │
|
|
1075
|
+
* │ "cherry" │
|
|
1076
|
+
* └──────────┘
|
|
1077
|
+
* >>> df.withColumns($df.col("s").str.stripPrefix("df-").alias("stripped"))
|
|
1078
|
+
* shape: (3, 2)
|
|
1079
|
+
* ┌─────────────┬──────────┐
|
|
1080
|
+
* │ s │ stripped │
|
|
1081
|
+
* ├─────────────┼──────────┤
|
|
1082
|
+
* │ "HELLO" │ HELLO │
|
|
1083
|
+
* │ "World" │ World │
|
|
1084
|
+
* │ "df-script" │ script │
|
|
1085
|
+
* └─────────────┴──────────┘
|
|
657
1086
|
*/
|
|
658
|
-
|
|
1087
|
+
stripPrefix(prefix: string): any;
|
|
659
1088
|
/**
|
|
660
1089
|
* Strips matching suffix substring from end of string.
|
|
661
1090
|
* @param suffix Suffix substring to remove.
|
|
662
1091
|
* @returns ColumnExpression
|
|
663
1092
|
* @example
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
1093
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
1094
|
+
* >>> df
|
|
1095
|
+
* shape: (3, 1)
|
|
1096
|
+
* ┌──────────┐
|
|
1097
|
+
* │ s │
|
|
1098
|
+
* ├──────────┤
|
|
1099
|
+
* │ "apple" │
|
|
1100
|
+
* │ "banana" │
|
|
1101
|
+
* │ "cherry" │
|
|
1102
|
+
* └──────────┘
|
|
1103
|
+
* >>> df.withColumns($df.col("email").str.stripSuffix(".com").alias("stripped"))
|
|
1104
|
+
* shape: (2, 2)
|
|
1105
|
+
* ┌──────────────────┬────────────────┐
|
|
1106
|
+
* │ email │ stripped │
|
|
1107
|
+
* ├──────────────────┼────────────────┤
|
|
1108
|
+
* │ user@example.com │ user@example │
|
|
1109
|
+
* │ admin@test.org │ admin@test.org │
|
|
1110
|
+
* └──────────────────┴────────────────┘
|
|
672
1111
|
*/
|
|
673
|
-
|
|
1112
|
+
stripSuffix(suffix: string): any;
|
|
674
1113
|
/**
|
|
675
1114
|
* Extracts the last n characters of each string element.
|
|
676
1115
|
* @param n Number of characters to extract from the end of the string (default 1).
|
|
677
1116
|
* @returns ColumnExpression
|
|
678
1117
|
* @example
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
1118
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
1119
|
+
* >>> df
|
|
1120
|
+
* shape: (3, 1)
|
|
1121
|
+
* ┌──────────┐
|
|
1122
|
+
* │ s │
|
|
1123
|
+
* ├──────────┤
|
|
1124
|
+
* │ "apple" │
|
|
1125
|
+
* │ "banana" │
|
|
1126
|
+
* │ "cherry" │
|
|
1127
|
+
* └──────────┘
|
|
1128
|
+
* >>> df.withColumns($df.col("s").str.tail(3).alias("suffix"))
|
|
1129
|
+
* shape: (3, 2)
|
|
1130
|
+
* ┌──────────┬────────┐
|
|
1131
|
+
* │ s │ suffix │
|
|
1132
|
+
* ├──────────┼────────┤
|
|
1133
|
+
* │ "apple" │ ple │
|
|
1134
|
+
* │ "banana" │ ana │
|
|
1135
|
+
* │ "cherry" │ rry │
|
|
1136
|
+
* └──────────┴────────┘
|
|
688
1137
|
*/
|
|
689
1138
|
tail(n?: number): any;
|
|
690
1139
|
/**
|
|
691
1140
|
* Parses date/time string into Datetime.
|
|
1141
|
+
* @note [Timezone Compatibility]: Direct string parsing with timezone offsets relies on native `Intl.DateTimeFormat`
|
|
1142
|
+
* and `Date.UTC`. Unrecognized timezone identifiers safely default to `"UTC"`.
|
|
692
1143
|
* @param options Parsing configuration options.
|
|
693
1144
|
* @returns ColumnExpression
|
|
694
1145
|
* @example
|
|
695
|
-
|
|
696
|
-
|
|
1146
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
1147
|
+
* >>> df
|
|
1148
|
+
* shape: (1, 1)
|
|
1149
|
+
* ┌──────────────────────────┐
|
|
1150
|
+
* │ date │
|
|
1151
|
+
* ├──────────────────────────┤
|
|
1152
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
1153
|
+
* └──────────────────────────┘
|
|
1154
|
+
* >>> df.withColumns($df.col("d").str.strptime({ format: "%Y-%m-%d" }).alias("parsed"))
|
|
697
1155
|
* shape: (1, 2)
|
|
698
1156
|
* ┌────────────┬──────────────────────────┐
|
|
699
1157
|
* │ d │ parsed │
|
|
@@ -706,22 +1164,40 @@ export declare class StringExprNamespace {
|
|
|
706
1164
|
* Converts string casing to camelCase.
|
|
707
1165
|
* @returns ColumnExpression
|
|
708
1166
|
* @example
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
1167
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
1168
|
+
* >>> df
|
|
1169
|
+
* shape: (3, 1)
|
|
1170
|
+
* ┌──────────┐
|
|
1171
|
+
* │ s │
|
|
1172
|
+
* ├──────────┤
|
|
1173
|
+
* │ "apple" │
|
|
1174
|
+
* │ "banana" │
|
|
1175
|
+
* │ "cherry" │
|
|
1176
|
+
* └──────────┘
|
|
1177
|
+
* >>> df.withColumns($df.col("s").str.toCamelCase().alias("camel"))
|
|
1178
|
+
* shape: (3, 2)
|
|
1179
|
+
* ┌─────────────┬───────────┐
|
|
1180
|
+
* │ s │ camel │
|
|
1181
|
+
* ├─────────────┼───────────┤
|
|
1182
|
+
* │ "HELLO" │ hello │
|
|
1183
|
+
* │ "World" │ world │
|
|
1184
|
+
* │ "df-script" │ dfScript │
|
|
1185
|
+
* └─────────────┴───────────┘
|
|
717
1186
|
*/
|
|
718
|
-
|
|
1187
|
+
toCamelCase(): any;
|
|
719
1188
|
/**
|
|
720
1189
|
* Parses string into Date object.
|
|
721
1190
|
* @returns ColumnExpression
|
|
722
1191
|
* @example
|
|
723
|
-
|
|
724
|
-
|
|
1192
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
1193
|
+
* >>> df
|
|
1194
|
+
* shape: (1, 1)
|
|
1195
|
+
* ┌──────────────────────────┐
|
|
1196
|
+
* │ date │
|
|
1197
|
+
* ├──────────────────────────┤
|
|
1198
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
1199
|
+
* └──────────────────────────┘
|
|
1200
|
+
* >>> df.withColumns($df.col("d").str.toDate().alias("date"))
|
|
725
1201
|
* shape: (1, 2)
|
|
726
1202
|
* ┌────────────┬──────────────────────────┐
|
|
727
1203
|
* │ d │ date │
|
|
@@ -729,216 +1205,350 @@ export declare class StringExprNamespace {
|
|
|
729
1205
|
* │ 2026-05-20 │ 2026-05-20T00:00:00.000Z │
|
|
730
1206
|
* └────────────┴──────────────────────────┘
|
|
731
1207
|
*/
|
|
732
|
-
|
|
1208
|
+
toDate(): any;
|
|
733
1209
|
/**
|
|
734
1210
|
* Parses string into Datetime value.
|
|
735
1211
|
* @returns ColumnExpression
|
|
736
1212
|
* @example
|
|
737
|
-
|
|
738
|
-
|
|
1213
|
+
* >>> const df = $df.data({ date: ["2026-05-20T10:00:00.123Z"] })
|
|
1214
|
+
* >>> df
|
|
1215
|
+
* shape: (1, 1)
|
|
1216
|
+
* ┌──────────────────────────┐
|
|
1217
|
+
* │ date │
|
|
1218
|
+
* ├──────────────────────────┤
|
|
1219
|
+
* │ 2026-05-20T10:00:00.123Z │
|
|
1220
|
+
* └──────────────────────────┘
|
|
1221
|
+
* >>> df.withColumns($df.col("d").str.toDatetime().alias("dt"))
|
|
739
1222
|
* shape: (1, 2)
|
|
740
|
-
*
|
|
741
|
-
* │
|
|
742
|
-
*
|
|
743
|
-
* │ 2026-05-
|
|
744
|
-
*
|
|
1223
|
+
* ┌────────────┬──────────────────────────┐
|
|
1224
|
+
* │ d │ dt │
|
|
1225
|
+
* ├────────────┼──────────────────────────┤
|
|
1226
|
+
* │ 2026-05-20 │ 2026-05-20T00:00:00.000Z │
|
|
1227
|
+
* └────────────┴──────────────────────────┘
|
|
745
1228
|
*/
|
|
746
|
-
|
|
1229
|
+
toDatetime(): any;
|
|
747
1230
|
/**
|
|
748
1231
|
* Converts string into numeric decimal representation.
|
|
749
1232
|
* @param precision Optional precision limit.
|
|
750
1233
|
* @param scale Optional scale limit.
|
|
751
1234
|
* @returns ColumnExpression
|
|
752
1235
|
* @example
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
1236
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
1237
|
+
* >>> df
|
|
1238
|
+
* shape: (3, 1)
|
|
1239
|
+
* ┌──────────┐
|
|
1240
|
+
* │ s │
|
|
1241
|
+
* ├──────────┤
|
|
1242
|
+
* │ "apple" │
|
|
1243
|
+
* │ "banana" │
|
|
1244
|
+
* │ "cherry" │
|
|
1245
|
+
* └──────────┘
|
|
1246
|
+
* >>> df.withColumns($df.col("s").str.len().str.toDecimal().alias("num"))
|
|
1247
|
+
* shape: (3, 2)
|
|
1248
|
+
* ┌──────────┬─────┐
|
|
1249
|
+
* │ s │ num │
|
|
1250
|
+
* ├──────────┼─────┤
|
|
1251
|
+
* │ "apple" │ 5 │
|
|
1252
|
+
* │ "banana" │ 6 │
|
|
1253
|
+
* │ "cherry" │ 6 │
|
|
1254
|
+
* └──────────┴─────┘
|
|
761
1255
|
*/
|
|
762
|
-
|
|
1256
|
+
toDecimal(precision?: number, scale?: number): any;
|
|
763
1257
|
/**
|
|
764
1258
|
* Parses string into integer number.
|
|
765
1259
|
* @returns ColumnExpression
|
|
766
1260
|
* @example
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
1261
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
1262
|
+
* >>> df
|
|
1263
|
+
* shape: (3, 1)
|
|
1264
|
+
* ┌──────────┐
|
|
1265
|
+
* │ s │
|
|
1266
|
+
* ├──────────┤
|
|
1267
|
+
* │ "apple" │
|
|
1268
|
+
* │ "banana" │
|
|
1269
|
+
* │ "cherry" │
|
|
1270
|
+
* └──────────┘
|
|
1271
|
+
* >>> df.withColumns($df.col("s").str.len().str.toInteger().alias("num"))
|
|
1272
|
+
* shape: (3, 2)
|
|
1273
|
+
* ┌──────────┬─────┐
|
|
1274
|
+
* │ s │ num │
|
|
1275
|
+
* ├──────────┼─────┤
|
|
1276
|
+
* │ "apple" │ 5 │
|
|
1277
|
+
* │ "banana" │ 6 │
|
|
1278
|
+
* │ "cherry" │ 6 │
|
|
1279
|
+
* └──────────┴─────┘
|
|
775
1280
|
*/
|
|
776
|
-
|
|
1281
|
+
toInteger(): any;
|
|
777
1282
|
/**
|
|
778
1283
|
* Converts string casing to kebab-case.
|
|
779
1284
|
* @returns ColumnExpression
|
|
780
1285
|
* @example
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
1286
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
1287
|
+
* >>> df
|
|
1288
|
+
* shape: (3, 1)
|
|
1289
|
+
* ┌──────────┐
|
|
1290
|
+
* │ s │
|
|
1291
|
+
* ├──────────┤
|
|
1292
|
+
* │ "apple" │
|
|
1293
|
+
* │ "banana" │
|
|
1294
|
+
* │ "cherry" │
|
|
1295
|
+
* └──────────┘
|
|
1296
|
+
* >>> df.withColumns($df.col("s").str.toKebabCase().alias("kebab"))
|
|
1297
|
+
* shape: (3, 2)
|
|
1298
|
+
* ┌─────────────┬───────────┐
|
|
1299
|
+
* │ s │ kebab │
|
|
1300
|
+
* ├─────────────┼───────────┤
|
|
1301
|
+
* │ "HELLO" │ hello │
|
|
1302
|
+
* │ "World" │ world │
|
|
1303
|
+
* │ "df-script" │ df-script │
|
|
1304
|
+
* └─────────────┴───────────┘
|
|
789
1305
|
*/
|
|
790
|
-
|
|
1306
|
+
toKebabCase(): any;
|
|
791
1307
|
/**
|
|
792
1308
|
* Converts all string elements in the column to lowercase.
|
|
793
1309
|
* @returns ColumnExpression
|
|
794
1310
|
* @example
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
*
|
|
806
|
-
*
|
|
807
|
-
*
|
|
808
|
-
*
|
|
809
|
-
*
|
|
810
|
-
* │
|
|
811
|
-
*
|
|
812
|
-
* │
|
|
813
|
-
*
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
*/
|
|
817
|
-
to_lowercase(): any;
|
|
1311
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
1312
|
+
* >>> df
|
|
1313
|
+
* shape: (3, 1)
|
|
1314
|
+
* ┌──────────┐
|
|
1315
|
+
* │ s │
|
|
1316
|
+
* ├──────────┤
|
|
1317
|
+
* │ "apple" │
|
|
1318
|
+
* │ "banana" │
|
|
1319
|
+
* │ "cherry" │
|
|
1320
|
+
* └──────────┘
|
|
1321
|
+
* >>> df.withColumns($df.col("s").str.toLowerCase().alias("lower_name"))
|
|
1322
|
+
* shape: (3, 2)
|
|
1323
|
+
* ┌─────────────┬────────────┐
|
|
1324
|
+
* │ s │ lower_name │
|
|
1325
|
+
* ├─────────────┼────────────┤
|
|
1326
|
+
* │ "HELLO" │ hello │
|
|
1327
|
+
* │ "World" │ world │
|
|
1328
|
+
* │ "df-script" │ df-script │
|
|
1329
|
+
* └─────────────┴────────────┘
|
|
1330
|
+
*/
|
|
1331
|
+
toLowerCase(): any;
|
|
818
1332
|
/**
|
|
819
1333
|
* Converts string casing to PascalCase.
|
|
820
1334
|
* @returns ColumnExpression
|
|
821
1335
|
* @example
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
1336
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
1337
|
+
* >>> df
|
|
1338
|
+
* shape: (3, 1)
|
|
1339
|
+
* ┌──────────┐
|
|
1340
|
+
* │ s │
|
|
1341
|
+
* ├──────────┤
|
|
1342
|
+
* │ "apple" │
|
|
1343
|
+
* │ "banana" │
|
|
1344
|
+
* │ "cherry" │
|
|
1345
|
+
* └──────────┘
|
|
1346
|
+
* >>> df.withColumns($df.col("s").str.toPascalCase().alias("pascal"))
|
|
1347
|
+
* shape: (3, 2)
|
|
1348
|
+
* ┌─────────────┬───────────┐
|
|
1349
|
+
* │ s │ pascal │
|
|
1350
|
+
* ├─────────────┼───────────┤
|
|
1351
|
+
* │ "HELLO" │ Hello │
|
|
1352
|
+
* │ "World" │ World │
|
|
1353
|
+
* │ "df-script" │ DfScript │
|
|
1354
|
+
* └─────────────┴───────────┘
|
|
830
1355
|
*/
|
|
831
|
-
|
|
1356
|
+
toPascalCase(): any;
|
|
832
1357
|
/**
|
|
833
1358
|
* Converts string casing to snake_case.
|
|
834
1359
|
* @returns ColumnExpression
|
|
835
1360
|
* @example
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
1361
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
1362
|
+
* >>> df
|
|
1363
|
+
* shape: (3, 1)
|
|
1364
|
+
* ┌──────────┐
|
|
1365
|
+
* │ s │
|
|
1366
|
+
* ├──────────┤
|
|
1367
|
+
* │ "apple" │
|
|
1368
|
+
* │ "banana" │
|
|
1369
|
+
* │ "cherry" │
|
|
1370
|
+
* └──────────┘
|
|
1371
|
+
* >>> df.withColumns($df.col("s").str.toSnakeCase().alias("snake"))
|
|
1372
|
+
* shape: (3, 2)
|
|
1373
|
+
* ┌─────────────┬───────────┐
|
|
1374
|
+
* │ s │ snake │
|
|
1375
|
+
* ├─────────────┼───────────┤
|
|
1376
|
+
* │ "HELLO" │ hello │
|
|
1377
|
+
* │ "World" │ world │
|
|
1378
|
+
* │ "df-script" │ df_script │
|
|
1379
|
+
* └─────────────┴───────────┘
|
|
844
1380
|
*/
|
|
845
|
-
|
|
1381
|
+
toSnakeCase(): any;
|
|
846
1382
|
/**
|
|
847
1383
|
* Parses string into time component representation.
|
|
848
1384
|
* @returns ColumnExpression
|
|
849
1385
|
* @example
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
1386
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
1387
|
+
* >>> df
|
|
1388
|
+
* shape: (3, 1)
|
|
1389
|
+
* ┌──────────┐
|
|
1390
|
+
* │ s │
|
|
1391
|
+
* ├──────────┤
|
|
1392
|
+
* │ "apple" │
|
|
1393
|
+
* │ "banana" │
|
|
1394
|
+
* │ "cherry" │
|
|
1395
|
+
* └──────────┘
|
|
1396
|
+
* >>> df.withColumns($df.col("s").str.toTime().alias("time"))
|
|
1397
|
+
* shape: (3, 2)
|
|
1398
|
+
* ┌──────────┬──────┐
|
|
1399
|
+
* │ s │ time │
|
|
1400
|
+
* ├──────────┼──────┤
|
|
1401
|
+
* │ "apple" │ null │
|
|
1402
|
+
* │ "banana" │ null │
|
|
1403
|
+
* │ "cherry" │ null │
|
|
1404
|
+
* └──────────┴──────┘
|
|
858
1405
|
*/
|
|
859
|
-
|
|
1406
|
+
toTime(): any;
|
|
860
1407
|
/**
|
|
861
1408
|
* Converts string casing to Title Case.
|
|
862
1409
|
* @returns ColumnExpression
|
|
863
1410
|
* @example
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
1411
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
1412
|
+
* >>> df
|
|
1413
|
+
* shape: (3, 1)
|
|
1414
|
+
* ┌──────────┐
|
|
1415
|
+
* │ s │
|
|
1416
|
+
* ├──────────┤
|
|
1417
|
+
* │ "apple" │
|
|
1418
|
+
* │ "banana" │
|
|
1419
|
+
* │ "cherry" │
|
|
1420
|
+
* └──────────┘
|
|
1421
|
+
* >>> df.withColumns($df.col("s").str.toTitleCase().alias("title"))
|
|
1422
|
+
* shape: (3, 2)
|
|
1423
|
+
* ┌─────────────┬───────────┐
|
|
1424
|
+
* │ s │ title │
|
|
1425
|
+
* ├─────────────┼───────────┤
|
|
1426
|
+
* │ "HELLO" │ Hello │
|
|
1427
|
+
* │ "World" │ World │
|
|
1428
|
+
* │ "df-script" │ Df Script │
|
|
1429
|
+
* └─────────────┴───────────┘
|
|
872
1430
|
*/
|
|
873
|
-
|
|
1431
|
+
toTitleCase(): any;
|
|
874
1432
|
/**
|
|
875
1433
|
* Converts all string elements in the column to uppercase.
|
|
876
1434
|
* @returns ColumnExpression
|
|
877
1435
|
* @example
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
1436
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
1437
|
+
* >>> df
|
|
1438
|
+
* shape: (3, 1)
|
|
1439
|
+
* ┌──────────┐
|
|
1440
|
+
* │ s │
|
|
1441
|
+
* ├──────────┤
|
|
1442
|
+
* │ "apple" │
|
|
1443
|
+
* │ "banana" │
|
|
1444
|
+
* │ "cherry" │
|
|
1445
|
+
* └──────────┘
|
|
1446
|
+
* >>> df.withColumns($df.col("s").str.toUpperCase().alias("upper"))
|
|
1447
|
+
* shape: (3, 2)
|
|
1448
|
+
* ┌─────────────┬───────────┐
|
|
1449
|
+
* │ s │ upper │
|
|
1450
|
+
* ├─────────────┼───────────┤
|
|
1451
|
+
* │ "HELLO" │ HELLO │
|
|
1452
|
+
* │ "World" │ WORLD │
|
|
1453
|
+
* │ "df-script" │ DF-SCRIPT │
|
|
1454
|
+
* └─────────────┴───────────┘
|
|
886
1455
|
*/
|
|
887
|
-
|
|
1456
|
+
toUpperCase(): any;
|
|
888
1457
|
/**
|
|
889
1458
|
* Trims leading and trailing whitespace characters from each string element.
|
|
890
1459
|
* @returns ColumnExpression
|
|
891
1460
|
* @example
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
1461
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
1462
|
+
* >>> df
|
|
1463
|
+
* shape: (3, 1)
|
|
1464
|
+
* ┌──────────┐
|
|
1465
|
+
* │ s │
|
|
1466
|
+
* ├──────────┤
|
|
1467
|
+
* │ "apple" │
|
|
1468
|
+
* │ "banana" │
|
|
1469
|
+
* │ "cherry" │
|
|
1470
|
+
* └──────────┘
|
|
1471
|
+
* >>> df.withColumns($df.col("s").str.trim().alias("clean"))
|
|
1472
|
+
* shape: (2, 2)
|
|
1473
|
+
* ┌─────────────┬───────┐
|
|
1474
|
+
* │ s │ clean │
|
|
1475
|
+
* ├─────────────┼───────┤
|
|
1476
|
+
* │ " hello " │ hello │
|
|
1477
|
+
* │ " world " │ world │
|
|
1478
|
+
* └─────────────┴───────┘
|
|
900
1479
|
*/
|
|
901
1480
|
trim(): any;
|
|
902
1481
|
/**
|
|
903
1482
|
* Trims trailing whitespace characters from each string element.
|
|
904
1483
|
* @returns ColumnExpression
|
|
905
1484
|
* @example
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
1485
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
1486
|
+
* >>> df
|
|
1487
|
+
* shape: (3, 1)
|
|
1488
|
+
* ┌──────────┐
|
|
1489
|
+
* │ s │
|
|
1490
|
+
* ├──────────┤
|
|
1491
|
+
* │ "apple" │
|
|
1492
|
+
* │ "banana" │
|
|
1493
|
+
* │ "cherry" │
|
|
1494
|
+
* └──────────┘
|
|
1495
|
+
* >>> df.withColumns($df.col("s").str.trimEnd().alias("clean"))
|
|
1496
|
+
* shape: (2, 2)
|
|
1497
|
+
* ┌─────────────┬──────────┐
|
|
1498
|
+
* │ s │ clean │
|
|
1499
|
+
* ├─────────────┼──────────┤
|
|
1500
|
+
* │ " hello " │ " hello" │
|
|
1501
|
+
* │ " world " │ " world" │
|
|
1502
|
+
* └─────────────┴──────────┘
|
|
914
1503
|
*/
|
|
915
|
-
|
|
1504
|
+
trimEnd(): any;
|
|
916
1505
|
/**
|
|
917
1506
|
* Trims leading whitespace characters from each string element.
|
|
918
1507
|
* @returns ColumnExpression
|
|
919
1508
|
* @example
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
1509
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
1510
|
+
* >>> df
|
|
1511
|
+
* shape: (3, 1)
|
|
1512
|
+
* ┌──────────┐
|
|
1513
|
+
* │ s │
|
|
1514
|
+
* ├──────────┤
|
|
1515
|
+
* │ "apple" │
|
|
1516
|
+
* │ "banana" │
|
|
1517
|
+
* │ "cherry" │
|
|
1518
|
+
* └──────────┘
|
|
1519
|
+
* >>> df.withColumns($df.col("s").str.trimStart().alias("clean"))
|
|
1520
|
+
* shape: (2, 2)
|
|
1521
|
+
* ┌─────────────┬──────────┐
|
|
1522
|
+
* │ s │ clean │
|
|
1523
|
+
* ├─────────────┼──────────┤
|
|
1524
|
+
* │ " hello " │ "hello "│
|
|
1525
|
+
* │ " world " │ "world "│
|
|
1526
|
+
* └─────────────┴──────────┘
|
|
928
1527
|
*/
|
|
929
|
-
|
|
1528
|
+
trimStart(): any;
|
|
930
1529
|
/**
|
|
931
1530
|
* Converts string to uppercase.
|
|
932
1531
|
* @returns ColumnExpression
|
|
933
1532
|
* @example
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
1533
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
1534
|
+
* >>> df
|
|
1535
|
+
* shape: (3, 1)
|
|
1536
|
+
* ┌──────────┐
|
|
1537
|
+
* │ s │
|
|
1538
|
+
* ├──────────┤
|
|
1539
|
+
* │ "apple" │
|
|
1540
|
+
* │ "banana" │
|
|
1541
|
+
* │ "cherry" │
|
|
1542
|
+
* └──────────┘
|
|
1543
|
+
* >>> df.withColumns($df.col("s").str.upper().alias("upper"))
|
|
1544
|
+
* shape: (3, 2)
|
|
1545
|
+
* ┌─────────────┬───────────┐
|
|
1546
|
+
* │ s │ upper │
|
|
1547
|
+
* ├─────────────┼───────────┤
|
|
1548
|
+
* │ "HELLO" │ HELLO │
|
|
1549
|
+
* │ "World" │ WORLD │
|
|
1550
|
+
* │ "df-script" │ DF-SCRIPT │
|
|
1551
|
+
* └─────────────┴───────────┘
|
|
942
1552
|
*/
|
|
943
1553
|
upper(): any;
|
|
944
1554
|
/**
|
|
@@ -946,14 +1556,25 @@ export declare class StringExprNamespace {
|
|
|
946
1556
|
* @param width Minimum resulting string width.
|
|
947
1557
|
* @returns ColumnExpression
|
|
948
1558
|
* @example
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
1559
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
1560
|
+
* >>> df
|
|
1561
|
+
* shape: (3, 1)
|
|
1562
|
+
* ┌──────────┐
|
|
1563
|
+
* │ s │
|
|
1564
|
+
* ├──────────┤
|
|
1565
|
+
* │ "apple" │
|
|
1566
|
+
* │ "banana" │
|
|
1567
|
+
* │ "cherry" │
|
|
1568
|
+
* └──────────┘
|
|
1569
|
+
* >>> df.withColumns($df.col("s").str.zfill(8).alias("padded"))
|
|
1570
|
+
* shape: (3, 2)
|
|
1571
|
+
* ┌──────────┬──────────┐
|
|
1572
|
+
* │ s │ padded │
|
|
1573
|
+
* ├──────────┼──────────┤
|
|
1574
|
+
* │ "apple" │ 000apple │
|
|
1575
|
+
* │ "banana" │ 00banana │
|
|
1576
|
+
* │ "cherry" │ 00cherry │
|
|
1577
|
+
* └──────────┴──────────┘
|
|
957
1578
|
*/
|
|
958
1579
|
zfill(width: number): any;
|
|
959
1580
|
}
|
|
@@ -965,7 +1586,25 @@ export declare class StringExpr extends ExprBase {
|
|
|
965
1586
|
* @syntax $df.col(<column_name>).str
|
|
966
1587
|
* @returns StringExprNamespace
|
|
967
1588
|
* @example
|
|
968
|
-
|
|
1589
|
+
* >>> const df = $df.data({ s: ["apple", "banana", "cherry"] })
|
|
1590
|
+
* >>> df
|
|
1591
|
+
* shape: (3, 1)
|
|
1592
|
+
* ┌──────────┐
|
|
1593
|
+
* │ s │
|
|
1594
|
+
* ├──────────┤
|
|
1595
|
+
* │ "apple" │
|
|
1596
|
+
* │ "banana" │
|
|
1597
|
+
* │ "cherry" │
|
|
1598
|
+
* └──────────┘
|
|
1599
|
+
* >>> df.select($df.col("s").str.len())
|
|
1600
|
+
* shape: (3, 1)
|
|
1601
|
+
* ┌─────┐
|
|
1602
|
+
* │ len │
|
|
1603
|
+
* ├─────┤
|
|
1604
|
+
* │ 5 │
|
|
1605
|
+
* │ 6 │
|
|
1606
|
+
* │ 6 │
|
|
1607
|
+
* └─────┘
|
|
969
1608
|
*/
|
|
970
1609
|
get str(): StringExprNamespace;
|
|
971
1610
|
}
|