@@ -51,8 +51,8 @@ export interface ExprString {
51
51
* └─────────┘
52
52
* ```
53
53
*/
54
- decode ( encoding : "hex" | "base64" , strict ?: boolean ) : Expr
55
- decode ( options : { encoding : "hex" | "base64" , strict ?: boolean } ) : Expr
54
+ decode ( encoding : "hex" | "base64" , strict ?: boolean ) : Expr ;
55
+ decode ( options : { encoding : "hex" | "base64" ; strict ?: boolean } ) : Expr ;
56
56
/**
57
57
* Encodes a value using the provided encoding
58
58
* @param encoding - hex | base64
@@ -74,7 +74,7 @@ export interface ExprString {
74
74
* └─────────┘
75
75
* ```
76
76
*/
77
- encode ( encoding : "hex" | "base64" ) : Expr
77
+ encode ( encoding : "hex" | "base64" ) : Expr ;
78
78
/**
79
79
* Extract the target capture group from provided patterns.
80
80
* @param pattern A valid regex pattern
@@ -140,7 +140,7 @@ export interface ExprString {
140
140
/** Get length of the string values in the Series. */
141
141
lengths ( ) : Expr ;
142
142
/** Remove leading whitespace. */
143
- lstrip ( ) : Expr
143
+ lstrip ( ) : Expr ;
144
144
/** Replace first regex match with a string value. */
145
145
replace ( pat : string | RegExp , val : string ) : Expr ;
146
146
/** Replace all regex matches with a string value. */
@@ -150,7 +150,105 @@ export interface ExprString {
150
150
/** Modify the strings to their uppercase equivalent. */
151
151
toUpperCase ( ) : Expr ;
152
152
/** Remove trailing whitespace. */
153
- rstrip ( ) : Expr
153
+ rstrip ( ) : Expr ;
154
+ /**
155
+ * Add a leading fillChar to a string until string length is reached.
156
+ * If string is longer or equal to given length no modifications will be done
157
+ * @param {number } length - of the final string
158
+ * @param {string } fillChar - that will fill the string.
159
+ * @note If a string longer than 1 character is provided only the first character will be used
160
+ * @example
161
+ * ```
162
+ * > df = pl.DataFrame({
163
+ * ... 'foo': [
164
+ * ... "a",
165
+ * ... "b",
166
+ * ... "LONG_WORD",
167
+ * ... "cow"
168
+ * ... ]})
169
+ * > df.select(pl.col('foo').str.padStart("_", 3)
170
+ * shape: (4, 1)
171
+ * ┌──────────┐
172
+ * │ a │
173
+ * │ -------- │
174
+ * │ str │
175
+ * ╞══════════╡
176
+ * │ __a │
177
+ * ├╌╌╌╌╌╌╌╌╌╌┤
178
+ * │ __b │
179
+ * ├╌╌╌╌╌╌╌╌╌╌┤
180
+ * │ LONG_WORD│
181
+ * ├╌╌╌╌╌╌╌╌╌╌┤
182
+ * │ cow │
183
+ * └──────────┘
184
+ * ```
185
+ */
186
+ padStart ( length : number , fillChar : string ) : Expr ;
187
+ /**
188
+ * Add leading "0" to a string until string length is reached.
189
+ * If string is longer or equal to given length no modifications will be done
190
+ * @param {number } length - of the final string
191
+ * @see {@link padStart }
192
+ * * @example
193
+ * ```
194
+ * > df = pl.DataFrame({
195
+ * ... 'foo': [
196
+ * ... "a",
197
+ * ... "b",
198
+ * ... "LONG_WORD",
199
+ * ... "cow"
200
+ * ... ]})
201
+ * > df.select(pl.col('foo').str.justify(3)
202
+ * shape: (4, 1)
203
+ * ┌──────────┐
204
+ * │ a │
205
+ * │ -------- │
206
+ * │ str │
207
+ * ╞══════════╡
208
+ * │ 00a │
209
+ * ├╌╌╌╌╌╌╌╌╌╌┤
210
+ * │ 00b │
211
+ * ├╌╌╌╌╌╌╌╌╌╌┤
212
+ * │ LONG_WORD│
213
+ * ├╌╌╌╌╌╌╌╌╌╌┤
214
+ * │ cow │
215
+ * └──────────┘
216
+ * ```
217
+ */
218
+ zFill ( length : number ) : Expr ;
219
+ /**
220
+ * Add a trailing fillChar to a string until string length is reached.
221
+ * If string is longer or equal to given length no modifications will be done
222
+ * @param {number } length - of the final string
223
+ * @param {string } fillChar - that will fill the string.
224
+ * @note If a string longer than 1 character is provided only the first character will be used
225
+ * * @example
226
+ * ```
227
+ * > df = pl.DataFrame({
228
+ * ... 'foo': [
229
+ * ... "a",
230
+ * ... "b",
231
+ * ... "LONG_WORD",
232
+ * ... "cow"
233
+ * ... ]})
234
+ * > df.select(pl.col('foo').str.padEnd("_", 3)
235
+ * shape: (4, 1)
236
+ * ┌──────────┐
237
+ * │ a │
238
+ * │ -------- │
239
+ * │ str │
240
+ * ╞══════════╡
241
+ * │ a__ │
242
+ * ├╌╌╌╌╌╌╌╌╌╌┤
243
+ * │ b__ │
244
+ * ├╌╌╌╌╌╌╌╌╌╌┤
245
+ * │ LONG_WORD│
246
+ * ├╌╌╌╌╌╌╌╌╌╌┤
247
+ * │ cow │
248
+ * └──────────┘
249
+ * ```
250
+ */
251
+ padEnd ( length : number , fillChar : string ) : Expr ;
154
252
/**
155
253
* Create subslices of the string values of a Utf8 Series.
156
254
* @param start - Start of the slice (negative indexing may be used).
@@ -162,16 +260,16 @@ export interface ExprString {
162
260
* @param separator — A string that identifies character or characters to use in separating the string.
163
261
* @param inclusive Include the split character/string in the results
164
262
*/
165
- split ( by : string , options ?: { inclusive ?: boolean } | boolean ) : Expr
263
+ split ( by : string , options ?: { inclusive ?: boolean } | boolean ) : Expr ;
166
264
/** Remove leading and trailing whitespace. */
167
- strip ( ) : Expr
265
+ strip ( ) : Expr ;
168
266
/**
169
267
* Parse a Series of dtype Utf8 to a Date/Datetime Series.
170
268
* @param datatype Date or Datetime.
171
269
* @param fmt formatting syntax. [Read more](https://docs.rs/chrono/0.4.19/chrono/format/strftime/index.html)
172
270
*/
173
- strptime ( datatype : DataType . Date , fmt ?: string ) : Expr
174
- strptime ( datatype : DataType . Datetime , fmt ?: string ) : Expr
271
+ strptime ( datatype : DataType . Date , fmt ?: string ) : Expr ;
272
+ strptime ( datatype : DataType . Datetime , fmt ?: string ) : Expr ;
175
273
}
176
274
177
275
export const ExprStringFunctions = ( _expr : any ) : ExprString => {
@@ -235,6 +333,15 @@ export const ExprStringFunctions = (_expr: any): ExprString => {
235
333
rstrip ( ) {
236
334
return wrap ( "strRstrip" ) ;
237
335
} ,
336
+ padStart ( length : number , fillChar : string ) {
337
+ return wrap ( "strPadStart" , length , fillChar ) ;
338
+ } ,
339
+ zFill ( length : number ) {
340
+ return wrap ( "strZFill" , length ) ;
341
+ } ,
342
+ padEnd ( length : number , fillChar : string ) {
343
+ return wrap ( "strPadEnd" , length , fillChar ) ;
344
+ } ,
238
345
slice ( start : number , length ?: number ) {
239
346
return wrap ( "strSlice" , start , length ) ;
240
347
} ,
0 commit comments