@ohos-ports/nodejs-polars 0.22.2-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/LICENSE +19 -0
  2. package/README.md +217 -0
  3. package/bin/cfg.d.ts +156 -0
  4. package/bin/cfg.js +52 -0
  5. package/bin/dataframe.d.ts +2008 -0
  6. package/bin/dataframe.js +771 -0
  7. package/bin/datatypes/conversion.d.ts +2 -0
  8. package/bin/datatypes/conversion.js +2 -0
  9. package/bin/datatypes/datatype.d.ts +252 -0
  10. package/bin/datatypes/datatype.js +386 -0
  11. package/bin/datatypes/field.d.ts +26 -0
  12. package/bin/datatypes/field.js +36 -0
  13. package/bin/datatypes/index.d.ts +42 -0
  14. package/bin/datatypes/index.js +119 -0
  15. package/bin/error.d.ts +7 -0
  16. package/bin/error.js +17 -0
  17. package/bin/functions.d.ts +26 -0
  18. package/bin/functions.js +208 -0
  19. package/bin/groupby.d.ts +173 -0
  20. package/bin/groupby.js +156 -0
  21. package/bin/html.d.ts +4 -0
  22. package/bin/html.js +18 -0
  23. package/bin/index.d.ts +252 -0
  24. package/bin/index.js +265 -0
  25. package/bin/internals/construction.d.ts +7 -0
  26. package/bin/internals/construction.js +237 -0
  27. package/bin/internals/polars_internal.d.ts +2 -0
  28. package/bin/internals/polars_internal.js +7 -0
  29. package/bin/io.d.ts +421 -0
  30. package/bin/io.js +332 -0
  31. package/bin/lazy/dataframe.d.ts +693 -0
  32. package/bin/lazy/dataframe.js +421 -0
  33. package/bin/lazy/expr/datetime.d.ts +8 -0
  34. package/bin/lazy/expr/datetime.js +25 -0
  35. package/bin/lazy/expr/index.d.ts +1155 -0
  36. package/bin/lazy/expr/index.js +629 -0
  37. package/bin/lazy/expr/list.d.ts +8 -0
  38. package/bin/lazy/expr/list.js +115 -0
  39. package/bin/lazy/expr/string.d.ts +534 -0
  40. package/bin/lazy/expr/string.js +131 -0
  41. package/bin/lazy/expr/struct.d.ts +126 -0
  42. package/bin/lazy/expr/struct.js +26 -0
  43. package/bin/lazy/functions.d.ts +620 -0
  44. package/bin/lazy/functions.js +691 -0
  45. package/bin/lazy/groupby.d.ts +24 -0
  46. package/bin/lazy/groupby.js +22 -0
  47. package/bin/lazy/index.d.ts +4 -0
  48. package/bin/lazy/index.js +20 -0
  49. package/bin/lazy/whenthen.d.ts +67 -0
  50. package/bin/lazy/whenthen.js +81 -0
  51. package/bin/native-polars.d.ts +2 -0
  52. package/bin/native-polars.js +267 -0
  53. package/bin/series/datetime.d.ts +8 -0
  54. package/bin/series/datetime.js +25 -0
  55. package/bin/series/index.d.ts +1116 -0
  56. package/bin/series/index.js +689 -0
  57. package/bin/series/list.d.ts +8 -0
  58. package/bin/series/list.js +87 -0
  59. package/bin/series/string.d.ts +300 -0
  60. package/bin/series/string.js +125 -0
  61. package/bin/series/struct.d.ts +36 -0
  62. package/bin/series/struct.js +35 -0
  63. package/bin/shared_traits.d.ts +1325 -0
  64. package/bin/shared_traits.js +2 -0
  65. package/bin/sql.d.ts +244 -0
  66. package/bin/sql.js +63 -0
  67. package/bin/types.d.ts +284 -0
  68. package/bin/types.js +2 -0
  69. package/bin/utils.d.ts +38 -0
  70. package/bin/utils.js +69 -0
  71. package/package.json +51 -0
@@ -0,0 +1,1116 @@
1
+ import { DataFrame } from "../dataframe";
2
+ import { type Bool, DataType, type DTypeToJs, type DTypeToJsLoose, type DtypeToJsName, type JsToDtype, type JsType, type Optional } from "../datatypes";
3
+ import type { Arithmetic, Comparison, Cumulative, Deserialize, EwmOps, Rolling, Round, Sample, Serialize } from "../shared_traits";
4
+ import type { InterpolationMethod, RankMethod } from "../types";
5
+ import { SeriesDateFunctions } from "./datetime";
6
+ import { SeriesListFunctions } from "./list";
7
+ import { SeriesStringFunctions } from "./string";
8
+ import { SeriesStructFunctions } from "./struct";
9
+ export type { SeriesDateFunctions as DatetimeSeries } from "./datetime";
10
+ export type { SeriesListFunctions as ListSeries } from "./list";
11
+ export type { SeriesStringFunctions as StringSeries } from "./string";
12
+ export type { SeriesStructFunctions as StructSeries } from "./struct";
13
+ declare const inspect: unique symbol;
14
+ /**
15
+ * A Series represents a single column in a polars DataFrame.
16
+ */
17
+ export interface Series<T extends DataType = any, Name extends string = string> extends ArrayLike<T>, Rolling<Series<T>>, Arithmetic<Series<T>>, Comparison<Series<T>>, Cumulative<Series<T>>, Round<Series<T>>, Sample<Series<T>>, EwmOps<Series<T>>, Serialize {
18
+ inner(): any;
19
+ name: Name;
20
+ dtype: T;
21
+ str: SeriesStringFunctions;
22
+ lst: SeriesListFunctions;
23
+ struct: SeriesStructFunctions;
24
+ date: SeriesDateFunctions;
25
+ [inspect](): string;
26
+ [Symbol.iterator](): IterableIterator<DTypeToJs<T>>;
27
+ bitand(other: Series<T>): Series<T, Name>;
28
+ bitor(other: Series<T>): Series<T, Name>;
29
+ bitxor(other: Series<T>): Series<T, Name>;
30
+ /**
31
+ * Take absolute values
32
+ */
33
+ abs(): Series<T, Name>;
34
+ add(other: number | Series): Series;
35
+ /**
36
+ * __Rename this Series.__
37
+ *
38
+ * @param name - new name
39
+ * @see {@link rename}
40
+ */
41
+ alias<U extends string>(name: U): Series<T, U>;
42
+ /**
43
+ * __Append a Series to this one.__
44
+ * ___
45
+ * @param {Series} other - Series to append.
46
+ * @example
47
+ * > const s = pl.Series("a", [1, 2, 3])
48
+ * > const s2 = pl.Series("b", [4, 5, 6])
49
+ * > s.append(s2)
50
+ * shape: (6,)
51
+ * Series: 'a' [i64]
52
+ * [
53
+ * 1
54
+ * 2
55
+ * 3
56
+ * 4
57
+ * 5
58
+ * 6
59
+ * ]
60
+ */
61
+ append(other: Series): void;
62
+ /**
63
+ * Get the index of the maximal value.
64
+ */
65
+ argMax(): Optional<number>;
66
+ /**
67
+ * Get the index of the minimal value.
68
+ * @return int
69
+ * @example
70
+ * ```
71
+ * const s = pl.Series("a", [3, 2, 1]);
72
+ * s.arg_min()
73
+ * ```
74
+ */
75
+ argMin(): Optional<number>;
76
+ /**
77
+ * Get index values where Boolean Series evaluate True.
78
+ */
79
+ argTrue(): Series<T, Name>;
80
+ /**
81
+ * Get unique index as Series.
82
+ */
83
+ argUnique(): Series<T, Name>;
84
+ /**
85
+ * Get the index values that would sort this Series.
86
+ * ___
87
+ * @param descending - Sort in descending order.
88
+ * @param nullsLast - Place null values last instead of first.
89
+ * @return {SeriesType} indexes - Indexes that can be used to sort this array.
90
+ */
91
+ argSort(descending?: boolean, nullsLast?: boolean): Series<T, Name>;
92
+ argSort({ descending, nullsLast, }: {
93
+ descending?: boolean;
94
+ nullsLast?: boolean;
95
+ }): Series<T, Name>;
96
+ argSort({ reverse, // deprecated
97
+ nullsLast, }: {
98
+ reverse?: boolean;
99
+ nullsLast?: boolean;
100
+ }): Series<T, Name>;
101
+ argSort(): Series<T, Name>;
102
+ /**
103
+ * __Rename this Series.__
104
+ *
105
+ * @param name - new name
106
+ * @see {@link rename} {@link alias}
107
+ */
108
+ as<U extends string>(name: string): Series<T, U>;
109
+ /**
110
+ * Cast between data types.
111
+ */
112
+ cast<const U extends DataType>(dtype: U, strict?: boolean): Series<U>;
113
+ cast(dtype: DataType, strict?: boolean): Series;
114
+ /**
115
+ * Get the length of each individual chunk
116
+ */
117
+ chunkLengths(): Array<T>;
118
+ /**
119
+ * Cheap deep clones.
120
+ */
121
+ clone(): Series<T, Name>;
122
+ concat(other: Series<T>): Series<T, Name>;
123
+ /**
124
+ * __Quick summary statistics of a series. __
125
+ *
126
+ * Series with mixed datatypes will return summary statistics for the datatype of the first value.
127
+ * ___
128
+ * @example
129
+ * ```
130
+ * > const seriesNum = pl.Series([1,2,3,4,5])
131
+ * > series_num.describe()
132
+ *
133
+ * shape: (6, 2)
134
+ * ┌──────────────┬────────────────────┐
135
+ * │ statistic ┆ value │
136
+ * │ --- ┆ --- │
137
+ * │ str ┆ f64 │
138
+ * ╞══════════════╪════════════════════╡
139
+ * │ "min" ┆ 1 │
140
+ * ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
141
+ * │ "max" ┆ 5 │
142
+ * ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
143
+ * │ "null_count" ┆ 0.0 │
144
+ * ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
145
+ * │ "mean" ┆ 3 │
146
+ * ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
147
+ * │ "std" ┆ 1.5811388300841898 │
148
+ * ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
149
+ * │ "count" ┆ 5 │
150
+ * └──────────────┴────────────────────┘
151
+ *
152
+ * > series_str = pl.Series(["a", "a", None, "b", "c"])
153
+ * > series_str.describe()
154
+ *
155
+ * shape: (3, 2)
156
+ * ┌──────────────┬───────┐
157
+ * │ statistic ┆ value │
158
+ * │ --- ┆ --- │
159
+ * │ str ┆ i64 │
160
+ * ╞══════════════╪═══════╡
161
+ * │ "unique" ┆ 4 │
162
+ * ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
163
+ * │ "null_count" ┆ 1 │
164
+ * ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┤
165
+ * │ "count" ┆ 5 │
166
+ * └──────────────┴───────┘
167
+ * ```
168
+ */
169
+ describe(): DataFrame;
170
+ /**
171
+ * Calculates the n-th discrete difference.
172
+ * @param n - number of slots to shift
173
+ * @param nullBehavior - `'ignore' | 'drop'`
174
+ */
175
+ diff(n: number, nullBehavior: "ignore" | "drop"): Series<T, Name>;
176
+ diff({ n, nullBehavior, }: {
177
+ n: number;
178
+ nullBehavior: "ignore" | "drop";
179
+ }): Series<T, Name>;
180
+ /**
181
+ * Compute the dot/inner product between two Series
182
+ * ___
183
+ * @example
184
+ * ```
185
+ * > const s = pl.Series("a", [1, 2, 3])
186
+ * > const s2 = pl.Series("b", [4.0, 5.0, 6.0])
187
+ * > s.dot(s2)
188
+ * 32.0
189
+ * ```
190
+ */
191
+ dot(other: Series): number | undefined | null;
192
+ /**
193
+ * Create a new Series that copies data from this Series without null values.
194
+ */
195
+ dropNulls(): Series<T, Name>;
196
+ /**
197
+ * __Explode a list or utf8 Series.__
198
+ *
199
+ * This means that every item is expanded to a new row.
200
+ * ___
201
+ * @example
202
+ * ```
203
+ * > const s = pl.Series('a', [[1, 2], [3, 4], [9, 10]])
204
+ * > s.explode()
205
+ * shape: (6,)
206
+ * Series: 'a' [i64]
207
+ * [
208
+ * 1
209
+ * 2
210
+ * 3
211
+ * 4
212
+ * 9
213
+ * 10
214
+ * ]
215
+ * ```
216
+ */
217
+ explode(): any;
218
+ /**
219
+ * Extend the Series with given number of values.
220
+ * @param value The value to extend the Series with. This value may be null to fill with nulls.
221
+ * @param n The number of values to extend.
222
+ */
223
+ extendConstant(value: any, n: number): Series;
224
+ extendConstant(opt: {
225
+ value: any;
226
+ n: number;
227
+ }): Series;
228
+ /**
229
+ * __Fill null values with a filling strategy.__
230
+ * ___
231
+ * @param strategy - Filling Strategy
232
+ * @example
233
+ * ```
234
+ * > const s = pl.Series("a", [1, 2, 3, None])
235
+ * > s.fill_null('forward'))
236
+ * shape: (4,)
237
+ * Series: '' [i64]
238
+ * [
239
+ * 1
240
+ * 2
241
+ * 3
242
+ * 3
243
+ * ]
244
+ * > s.fill_null('min'))
245
+ * shape: (4,)
246
+ * Series: 'a' [i64]
247
+ * [
248
+ * 1
249
+ * 2
250
+ * 3
251
+ * 1
252
+ * ]
253
+ * ```
254
+ */
255
+ fillNull(strategy: "backward" | "forward" | "min" | "max" | "mean" | "one" | "zero"): Series;
256
+ fillNull({ strategy, }: {
257
+ strategy: "backward" | "forward" | "min" | "max" | "mean" | "one" | "zero";
258
+ }): Series;
259
+ /**
260
+ * __Filter elements by a boolean mask.__
261
+ * @param {SeriesType} predicate - Boolean mask
262
+ */
263
+ filter(predicate: Series): Series;
264
+ filter({ predicate }: {
265
+ predicate: Series;
266
+ }): Series;
267
+ get(index: number): any;
268
+ getIndex(n: number): any;
269
+ /**
270
+ * Returns True if the Series has a validity bitmask.
271
+ * If there is none, it means that there are no null values.
272
+ */
273
+ hasValidity(): boolean;
274
+ /**
275
+ * Hash the Series
276
+ * The hash value is of type `UInt64`
277
+ * ___
278
+ * @param k0 - seed parameter
279
+ * @param k1 - seed parameter
280
+ * @param k2 - seed parameter
281
+ * @param k3 - seed parameter
282
+ * @example
283
+ * ```
284
+ * > const s = pl.Series("a", [1, 2, 3])
285
+ * > s.hash(42)
286
+ * shape: (3,)
287
+ * Series: 'a' [u64]
288
+ * [
289
+ * 7499844439152382372
290
+ * 821952831504499201
291
+ * 6685218033491627602
292
+ * ]
293
+ * ```
294
+ */
295
+ hash(k0?: number | bigint, k1?: number | bigint, k2?: number | bigint, k3?: number | bigint): Series;
296
+ hash({ k0, k1, k2, k3, }: {
297
+ k0?: number | bigint;
298
+ k1?: number | bigint;
299
+ k2?: number | bigint;
300
+ k3?: number | bigint;
301
+ }): Series;
302
+ /**
303
+ * __Get first N elements as Series.__
304
+ * ___
305
+ * @param length Length of the head
306
+ * @example
307
+ * ```
308
+ * > const s = pl.Series("a", [1, 2, 3])
309
+ * > s.head(2)
310
+ * shape: (2,)
311
+ * Series: 'a' [i64]
312
+ * [
313
+ * 1
314
+ * 2
315
+ * ]
316
+ * ```
317
+ */
318
+ head(length?: number): Series;
319
+ /**
320
+ * __Interpolate intermediate values.__
321
+ *
322
+ * The interpolation method is linear.
323
+ * ___
324
+ * @example
325
+ * ```
326
+ * > const s = pl.Series("a", [1, 2, None, None, 5])
327
+ * > s.interpolate()
328
+ * shape: (5,)
329
+ * Series: 'a' [i64]
330
+ * [
331
+ * 1
332
+ * 2
333
+ * 3
334
+ * 4
335
+ * 5
336
+ * ]
337
+ * ```
338
+ */
339
+ interpolate(method?: InterpolationMethod): Series;
340
+ /**
341
+ * Check if this Series is a Boolean.
342
+ */
343
+ isBoolean(): this is Series<Bool>;
344
+ /**
345
+ * Check if this Series is a DataTime.
346
+ */
347
+ isDateTime(): boolean;
348
+ /**
349
+ * __Get mask of all duplicated values.__
350
+ *
351
+ * @example
352
+ * ```
353
+ * > const s = pl.Series("a", [1, 2, 2, 3])
354
+ * > s.isDuplicated()
355
+ *
356
+ * shape: (4,)
357
+ * Series: 'a' [bool]
358
+ * [
359
+ * false
360
+ * true
361
+ * true
362
+ * false
363
+ * ]
364
+ * ```
365
+ */
366
+ isDuplicated(): Series;
367
+ /**
368
+ * Get mask of finite values if Series dtype is Float.
369
+ */
370
+ isFinite(): Series;
371
+ /**
372
+ * Get a mask of the first unique value.
373
+ */
374
+ isFirstDistinct(): Series;
375
+ /**
376
+ * Check if this Series is a Float.
377
+ */
378
+ isFloat(): boolean;
379
+ /**
380
+ * Check if elements of this Series are in the right Series, or List values of the right Series.
381
+ */
382
+ isIn<U>(other: Series | U[]): Series;
383
+ /**
384
+ * __Get mask of infinite values if Series dtype is Float.__
385
+ * @example
386
+ * ```
387
+ * > const s = pl.Series("a", [1.0, 2.0, 3.0])
388
+ * > s.isInfinite()
389
+ *
390
+ * shape: (3,)
391
+ * Series: 'a' [bool]
392
+ * [
393
+ * false
394
+ * false
395
+ * false
396
+ * ]
397
+ * ```
398
+ */
399
+ isInfinite(): Series;
400
+ /**
401
+ * __Get mask of non null values.__
402
+ *
403
+ * *`undefined` values are treated as null*
404
+ * ___
405
+ * @example
406
+ * ```
407
+ * > const s = pl.Series("a", [1.0, undefined, 2.0, 3.0, null])
408
+ * > s.isNotNull()
409
+ * shape: (5,)
410
+ * Series: 'a' [bool]
411
+ * [
412
+ * true
413
+ * false
414
+ * true
415
+ * true
416
+ * false
417
+ * ]
418
+ * ```
419
+ */
420
+ isNotNull(): Series;
421
+ /**
422
+ * __Get mask of null values.__
423
+ *
424
+ * `undefined` values are treated as null
425
+ * ___
426
+ * @example
427
+ * ```
428
+ * > const s = pl.Series("a", [1.0, undefined, 2.0, 3.0, null])
429
+ * > s.isNull()
430
+ * shape: (5,)
431
+ * Series: 'a' [bool]
432
+ * [
433
+ * false
434
+ * true
435
+ * false
436
+ * false
437
+ * true
438
+ * ]
439
+ * ```
440
+ */
441
+ isNull(): Series;
442
+ /**
443
+ * Check if this Series datatype is numeric.
444
+ */
445
+ isNumeric(): this is Series<DataType.Int8 | DataType.Int16 | DataType.Int32 | DataType.Int64 | DataType.UInt8 | DataType.UInt16 | DataType.UInt32 | DataType.UInt64 | DataType.Float32 | DataType.Float64 | DataType.Decimal>;
446
+ /**
447
+ * __Get mask of unique values.__
448
+ * ___
449
+ * @example
450
+ * ```
451
+ * > const s = pl.Series("a", [1, 2, 2, 3])
452
+ * > s.isUnique()
453
+ * shape: (4,)
454
+ * Series: 'a' [bool]
455
+ * [
456
+ * true
457
+ * false
458
+ * false
459
+ * true
460
+ * ]
461
+ * ```
462
+ */
463
+ isUnique(): Series;
464
+ /**
465
+ * Checks if this Series datatype is a String.
466
+ */
467
+ isString(): boolean;
468
+ /**
469
+ * __Compute the kurtosis (Fisher or Pearson) of a dataset.__
470
+ *
471
+ * Kurtosis is the fourth central moment divided by the square of the
472
+ * variance. If Fisher's definition is used, then 3.0 is subtracted from
473
+ * the result to give 0.0 for a normal distribution.
474
+ * If bias is False then the kurtosis is calculated using k statistics to
475
+ * eliminate bias coming from biased moment estimators
476
+ * ___
477
+ * @param fisher -
478
+ * - If True, Fisher's definition is used (normal ==> 0.0).
479
+ * - If False, Pearson's definition is used (normal ==> 3.0)
480
+ * @param bias : bool, optional If False, the calculations are corrected for statistical bias.
481
+ */
482
+ kurtosis(fisher: boolean, bias?: boolean): Optional<number>;
483
+ kurtosis({ fisher, bias, }: {
484
+ fisher?: boolean;
485
+ bias?: boolean;
486
+ }): Optional<number>;
487
+ kurtosis(): Optional<number>;
488
+ /**
489
+ * __Length of this Series.__
490
+ * ___
491
+ * @example
492
+ * ```
493
+ * > const s = pl.Series("a", [1, 2, 3])
494
+ * > s.len()
495
+ * 3
496
+ * ```
497
+ */
498
+ len(): number;
499
+ /**
500
+ * __Take `n` elements from this Series.__
501
+ * ___
502
+ * @param n - Amount of elements to take.
503
+ * @see {@link head}
504
+ * @example
505
+ * ```
506
+ * s = pl.Series("a", [1, 2, 3])
507
+ * s.limit(2)
508
+ * shape: (2,)
509
+ * Series: 'a' [i64]
510
+ * [
511
+ * 1
512
+ * 2
513
+ * ]
514
+ * ```
515
+ */
516
+ limit(n?: number): Series;
517
+ /**
518
+ * Get the maximum value in this Series.
519
+ * @example
520
+ * ```
521
+ * > s = pl.Series("a", [1, 2, 3])
522
+ * > s.max()
523
+ * 3
524
+ * ```
525
+ */
526
+ max(): number;
527
+ /**
528
+ * Reduce this Series to the mean value.
529
+ * @example
530
+ * ```
531
+ * > s = pl.Series("a", [1, 2, 3])
532
+ * > s.mean()
533
+ * 2
534
+ * ```
535
+ */
536
+ mean(): number;
537
+ /**
538
+ * Get the median of this Series
539
+ * @example
540
+ * ```
541
+ * > s = pl.Series("a", [1, 2, 3])
542
+ * > s.median()
543
+ * 2
544
+ * ```
545
+ */
546
+ median(): number;
547
+ /**
548
+ * Get the minimal value in this Series.
549
+ * @example
550
+ * ```
551
+ * > s = pl.Series("a", [1, 2, 3])
552
+ * > s.min()
553
+ * 1
554
+ * ```
555
+ */
556
+ min(): number;
557
+ /**
558
+ * __Compute the most occurring value(s). Can return multiple Values__
559
+ * ___
560
+ * @example
561
+ * ```
562
+ * s = pl.Series("a", [1, 2, 2, 3])
563
+ * s.mode()
564
+ * shape: (1,)
565
+ * Series: 'a' [i64]
566
+ * [
567
+ * 2
568
+ * ]
569
+ *
570
+ * s = pl.Series("a", ['a', 'b', 'c', 'c', 'b'])
571
+ * s.mode()
572
+ * shape: (1,)
573
+ * Series: 'a' [str]
574
+ * [
575
+ * 'b'
576
+ * 'c'
577
+ * ]
578
+ * ```
579
+ */
580
+ mode(): Series;
581
+ /**
582
+ * Get the number of chunks that this Series contains.
583
+ */
584
+ nChunks(): number;
585
+ /**
586
+ * __Count the number of unique values in this Series.__
587
+ * ___
588
+ * @example
589
+ * ```
590
+ * s = pl.Series("a", [1, 2, 2, 3])
591
+ * s.nUnique()
592
+ * 3
593
+ * ```
594
+ */
595
+ nUnique(): number;
596
+ /**
597
+ * Count the null values in this Series. --
598
+ * _`undefined` values are treated as null_
599
+ */
600
+ nullCount(): number;
601
+ /**
602
+ * Get a boolean mask of the local maximum peaks.
603
+ * ___
604
+ * @example
605
+ * ```
606
+ * s = pl.Series("a", [1, 2, 3, 4, 5])
607
+ * s.peakMax()
608
+ * shape: (5,)
609
+ * Series: '' [bool]
610
+ * [
611
+ * false
612
+ * false
613
+ * false
614
+ * false
615
+ * true
616
+ * ]
617
+ * ```
618
+ */
619
+ peakMax(): Series;
620
+ /**
621
+ * Get a boolean mask of the local minimum peaks.
622
+ * ___
623
+ * @example
624
+ * ```
625
+ * s = pl.Series("a", [4, 1, 3, 2, 5])
626
+ * s.peakMin()
627
+ * shape: (5,)
628
+ * Series: '' [bool]
629
+ * [
630
+ * false
631
+ * true
632
+ * false
633
+ * true
634
+ * false
635
+ * ]
636
+ * ```
637
+ */
638
+ peakMin(): Series;
639
+ /**
640
+ * Get the quantile value of this Series.
641
+ * ___
642
+ * @param quantile
643
+ * @example
644
+ * ```
645
+ * s = pl.Series("a", [1, 2, 3])
646
+ * s.quantile(0.5)
647
+ * 2
648
+ * ```
649
+ */
650
+ quantile(quantile: number, interpolation?: string): number;
651
+ /**
652
+ * Assign ranks to data, dealing with ties appropriately.
653
+ * The method used to assign ranks to tied elements.
654
+ * @param method {'average', 'min', 'max', 'dense', 'ordinal', 'random'}
655
+ * The following methods are available: _default is 'average'_
656
+ *
657
+ * * __'average'__: The average of the ranks that would have been assigned to
658
+ * all the tied values is assigned to each value.
659
+ * * __'min'__: The minimum of the ranks that would have been assigned to all
660
+ * the tied values is assigned to each value. _This is also
661
+ * referred to as "competition" ranking._
662
+ * * __'max'__: The maximum of the ranks that would have been assigned to all
663
+ * the tied values is assigned to each value.
664
+ * * __'dense'__: Like 'min', but the rank of the next highest element is
665
+ * assigned the rank immediately after those assigned to the tied
666
+ * elements.
667
+ * * __'ordinal'__: All values are given a distinct rank, corresponding to
668
+ * the order that the values occur in `a`.
669
+ * * __'random'__: Like 'ordinal', but the rank for ties is not dependent
670
+ * on the order that the values occur in `a`.
671
+ * @param descending - Rank in descending order.
672
+ */
673
+ rank(method?: RankMethod, descending?: boolean): Series;
674
+ rechunk(): Series;
675
+ rechunk(inPlace: true): Series;
676
+ rechunk(inPlace: false): void;
677
+ /**
678
+ * __Reinterpret the underlying bits as a signed/unsigned integer.__
679
+ *
680
+ * This operation is only allowed for 64bit integers. For lower bits integers,
681
+ * you can safely use that cast operation.
682
+ * ___
683
+ * @param signed signed or unsigned
684
+ *
685
+ * - True -> pl.Int64
686
+ * - False -> pl.UInt64
687
+ * @see {@link cast}
688
+ */
689
+ reinterpret(signed?: boolean): Series;
690
+ /**
691
+ * __Rename this Series.__
692
+ *
693
+ * @param name - new name
694
+ * @param inPlace - Modify the Series in-place.
695
+ * @see {@link alias}
696
+ * @example
697
+ * ```
698
+ * s = pl.Series("a", [1, 2, 3])
699
+ * s.rename('b')
700
+ * shape: (3,)
701
+ * Series: 'b' [i64]
702
+ * [
703
+ * 1
704
+ * 2
705
+ * 3
706
+ * ]
707
+ * ```
708
+ */
709
+ rename(name: string, inPlace: boolean): void;
710
+ rename(name: string): Series;
711
+ rename({ name, inPlace }: {
712
+ name: string;
713
+ inPlace?: boolean;
714
+ }): void;
715
+ rename({ name, inPlace }: {
716
+ name: string;
717
+ inPlace: true;
718
+ }): void;
719
+ /**
720
+ * __Check if series is equal with another Series.__
721
+ * @param other - Series to compare with.
722
+ * @param nullEqual - Consider null values as equal. _('undefined' is treated as null)_
723
+ * ___
724
+ * @example
725
+ * ```
726
+ * s = pl.Series("a", [1, 2, 3])
727
+ * s2 = pl.Series("b", [4, 5, 6])
728
+ * s.series_equal(s)
729
+ * true
730
+ * s.series_equal(s2)
731
+ * false
732
+ * ```
733
+ */
734
+ seriesEqual<_U1>(other: Series, nullEqual?: boolean, strict?: boolean): boolean;
735
+ /**
736
+ * __Set masked values__
737
+ * @param filter Boolean mask
738
+ * @param value value to replace masked values with
739
+ */
740
+ set(filter: Series, value: any): Series;
741
+ scatter(indices: number[] | Series, value: any): void;
742
+ /**
743
+ * __Shift the values by a given period__
744
+ *
745
+ * the parts that will be empty due to this operation will be filled with `null`.
746
+ * ___
747
+ * @param periods - Number of places to shift (may be negative).
748
+ * @example
749
+ * ```
750
+ * s = pl.Series("a", [1, 2, 3])
751
+ * s.shift(1)
752
+ * shape: (3,)
753
+ * Series: 'a' [i64]
754
+ * [
755
+ * null
756
+ * 1
757
+ * 2
758
+ * ]
759
+ * s.shift(-1)
760
+ * shape: (3,)
761
+ * Series: 'a' [i64]
762
+ * [
763
+ * 2
764
+ * 3
765
+ * null
766
+ * ]
767
+ * ```
768
+ */
769
+ shift(periods: number): Series;
770
+ /**
771
+ * Shift the values by a given period
772
+ *
773
+ * the parts that will be empty due to this operation will be filled with `fillValue`.
774
+ * ___
775
+ * @param periods - Number of places to shift (may be negative).
776
+ * @param fillValue - Fill null & undefined values with the result of this expression.
777
+ */
778
+ shiftAndFill(periods: number, fillValue: number): Series;
779
+ shiftAndFill(args: {
780
+ periods: number;
781
+ fillValue: number;
782
+ }): Series;
783
+ /**
784
+ * __Shrink memory usage of this Series to fit the exact capacity needed to hold the data.__
785
+ * @param inPlace - Modify the Series in-place.
786
+ */
787
+ shrinkToFit(inPlace: true): void;
788
+ shrinkToFit(): Series;
789
+ /**
790
+ * __Compute the sample skewness of a data set.__
791
+ *
792
+ * For normally distributed data, the skewness should be about zero. For
793
+ * unimodal continuous distributions, a skewness value greater than zero means
794
+ * that there is more weight in the right tail of the distribution. The
795
+ * function `skewtest` can be used to determine if the skewness value
796
+ * is close enough to zero, statistically speaking.
797
+ * ___
798
+ * @param bias - If false, then the calculations are corrected for statistical bias.
799
+ */
800
+ skew(bias?: boolean): number | undefined;
801
+ /**
802
+ * Create subslices of the Series.
803
+ *
804
+ * @param start - Start of the slice (negative indexing may be used).
805
+ * @param length - length of the slice.
806
+ */
807
+ slice(start: number, length?: number): Series;
808
+ /**
809
+ * __Sort this Series.__
810
+ * @param options.descending - Sort in descending order.
811
+ * @param options.nullsLast - Place nulls at the end.
812
+ * @example
813
+ * ```
814
+ * s = pl.Series("a", [1, 3, 4, 2])
815
+ * s.sort()
816
+ * shape: (4,)
817
+ * Series: 'a' [i64]
818
+ * [
819
+ * 1
820
+ * 2
821
+ * 3
822
+ * 4
823
+ * ]
824
+ * s.sort({descending: true})
825
+ * shape: (4,)
826
+ * Series: 'a' [i64]
827
+ * [
828
+ * 4
829
+ * 3
830
+ * 2
831
+ * 1
832
+ * ]
833
+ * ```
834
+ */
835
+ sort(options: {
836
+ descending?: boolean;
837
+ nullsLast?: boolean;
838
+ }): Series;
839
+ sort(options: {
840
+ reverse?: boolean;
841
+ nullsLast?: boolean;
842
+ }): Series;
843
+ sort(): Series;
844
+ /**
845
+ * Reduce this Series to the sum value.
846
+ * @example
847
+ * ```
848
+ * > s = pl.Series("a", [1, 2, 3])
849
+ * > s.sum()
850
+ * 6
851
+ * ```
852
+ */
853
+ sum(): number;
854
+ /**
855
+ * __Get last N elements as Series.__
856
+ *
857
+ * ___
858
+ * @param length - Length of the tail
859
+ * @see {@link head}
860
+ * @example
861
+ * ```
862
+ * s = pl.Series("a", [1, 2, 3])
863
+ * s.tail(2)
864
+ * shape: (2,)
865
+ * Series: 'a' [i64]
866
+ * [
867
+ * 2
868
+ * 3
869
+ * ]
870
+ * ```
871
+ */
872
+ tail(length?: number): Series;
873
+ /**
874
+ * Take every nth value in the Series and return as new Series.
875
+ * @param n - Gather every *n*-th row
876
+ * @param offset - Start the row count at this offset
877
+ * @example
878
+ * ```
879
+ * s = pl.Series("a", [1, 2, 3, 4])
880
+ * s.gatherEvery(2))
881
+ * shape: (2,)
882
+ * Series: 'a' [i64]
883
+ * [
884
+ * 1
885
+ * 3
886
+ * ]
887
+ * s.gather_every(2, offset=1)
888
+ * shape: (2,)
889
+ * Series: 'a' [i64]
890
+ * [
891
+ * 2
892
+ * 4
893
+ * ]
894
+ * ```
895
+ */
896
+ gatherEvery(n: number, offset?: number): Series;
897
+ /**
898
+ * Take values by index.
899
+ * ___
900
+ * @param indices - Index location used for the selection
901
+ * @example
902
+ * ```
903
+ * s = pl.Series("a", [1, 2, 3, 4])
904
+ * s.gather([1, 3])
905
+ * shape: (2,)
906
+ * Series: 'a' [i64]
907
+ * [
908
+ * 2
909
+ * 4
910
+ * ]
911
+ * ```
912
+ */
913
+ gather(indices: Array<number>): Series;
914
+ /**
915
+ * __Get unique elements in series.__
916
+ * ___
917
+ * @param maintainOrder Maintain order of data. This requires more work.
918
+ * @example
919
+ * ```
920
+ * s = pl.Series("a", [1, 2, 2, 3])
921
+ * s.unique()
922
+ * shape: (3,)
923
+ * Series: 'a' [i64]
924
+ * [
925
+ * 1
926
+ * 2
927
+ * 3
928
+ * ]
929
+ * ```
930
+ */
931
+ unique(maintainOrder?: boolean | {
932
+ maintainOrder: boolean;
933
+ }): Series;
934
+ /**
935
+ * __Count the unique values in a Series.__
936
+ * @param sort - Sort the output by count in descending order.
937
+ * If set to `False` (default), the order of the output is random.
938
+ * @param parallel - Execute the computation in parallel.
939
+ .. note::
940
+ This option should likely not be enabled in a group by context,
941
+ as the computation is already parallelized per group.
942
+ * @param name - Give the resulting count column a specific name;
943
+ if `normalize` is True defaults to "count", otherwise defaults to "proportion".
944
+ * @param normalize - If true gives relative frequencies of the unique values
945
+ * ___
946
+ * @example
947
+ * ```
948
+ * s = pl.Series("a", [1, 2, 2, 3])
949
+ * s.valueCounts()
950
+ * shape: (3, 2)
951
+ * ╭─────┬────────╮
952
+ * │ a ┆ counts │
953
+ * │ --- ┆ --- │
954
+ * │ i64 ┆ u32 │
955
+ * ╞═════╪════════╡
956
+ * │ 2 ┆ 2 │
957
+ * ├╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
958
+ * │ 1 ┆ 1 │
959
+ * ├╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
960
+ * │ 3 ┆ 1 │
961
+ * ╰─────┴────────╯
962
+ * ```
963
+ */
964
+ valueCounts(sort?: boolean, parallel?: boolean, name?: string, normalize?: boolean): DataFrame;
965
+ /**
966
+ * Where mask evaluates true, take values from self.
967
+ *
968
+ * Where mask evaluates false, take values from other.
969
+ * ___
970
+ * @param mask - Boolean Series
971
+ * @param other - Series of same type
972
+ */
973
+ zipWith(mask: Series, other: Series): Series;
974
+ /**
975
+ * __Convert this Series to a Javascript Array.__
976
+ *
977
+ * This operation clones data, and is very slow, but maintains greater precision for all dtypes.
978
+ * Often times `series.toObject().values` is faster, but less precise
979
+ * ___
980
+ * @example
981
+ * ```
982
+ * const s = pl.Series("a", [1, 2, 3])
983
+ * const arr = s.toArray()
984
+ * [1, 2, 3]
985
+ * Array.isArray(arr)
986
+ * true
987
+ * ```
988
+ */
989
+ toArray(): Array<DTypeToJs<T>>;
990
+ /**
991
+ * Converts series to a javascript typedArray.
992
+ *
993
+ * __Warning:__
994
+ * This will throw an error if you have nulls, or are using non numeric data types
995
+ */
996
+ toTypedArray(): any;
997
+ /**
998
+ * Get dummy/indicator variables.
999
+ * @param separator str = "_",
1000
+ * @param dropFirst bool = False
1001
+ * @param dropNulls bool = False,
1002
+ *
1003
+ * @example
1004
+ * const s = pl.Series("a", [1, 2, 3])
1005
+ >>> s.toDummies()
1006
+ shape: (3, 3)
1007
+ ┌─────┬─────┬─────┐
1008
+ │ a_1 ┆ a_2 ┆ a_3 │
1009
+ │ --- ┆ --- ┆ --- │
1010
+ │ u8 ┆ u8 ┆ u8 │
1011
+ ╞═════╪═════╪═════╡
1012
+ │ 1 ┆ 0 ┆ 0 │
1013
+ │ 0 ┆ 1 ┆ 0 │
1014
+ │ 0 ┆ 0 ┆ 1 │
1015
+ └─────┴─────┴─────┘
1016
+
1017
+ >>> s.toDummies(":", true)
1018
+ shape: (3, 2)
1019
+ ┌─────┬─────┐
1020
+ │ a:2 ┆ a:3 │
1021
+ │ --- ┆ --- │
1022
+ │ u8 ┆ u8 │
1023
+ ╞═════╪═════╡
1024
+ │ 0 ┆ 0 │
1025
+ │ 1 ┆ 0 │
1026
+ │ 0 ┆ 1 │
1027
+ └─────┴─────┘
1028
+ *
1029
+ */
1030
+ toDummies(separator?: string, dropFirst?: boolean, dropNulls?: boolean): DataFrame;
1031
+ /**
1032
+ * _Returns a Javascript object representation of Series_
1033
+ * Often this is much faster than the iterator, or `values` method
1034
+ *
1035
+ * @example
1036
+ * ```
1037
+ * const s = pl.Series("foo", [1,2,3])
1038
+ * s.toObject()
1039
+ * {
1040
+ * name: "foo",
1041
+ * datatype: "Float64",
1042
+ * values: [1,2,3]
1043
+ * }
1044
+ * ```
1045
+ */
1046
+ toObject(): {
1047
+ name: Name;
1048
+ datatype: DtypeToJsName<T>;
1049
+ values: DTypeToJs<T>[];
1050
+ };
1051
+ toFrame(): DataFrame;
1052
+ /** compat with `JSON.stringify */
1053
+ toJSON(): string;
1054
+ /** Returns an iterator over the values */
1055
+ values(): IterableIterator<any>;
1056
+ }
1057
+ /** @ignore */
1058
+ export declare function _Series(_s: any): Series;
1059
+ /**
1060
+ * @ignore
1061
+ * @inheritDoc {Series}
1062
+ */
1063
+ export interface SeriesConstructor extends Deserialize<Series> {
1064
+ /**
1065
+ * Creates a new Series from a set of values.
1066
+ * @param values — A set of values to include in the new Series object.
1067
+ * @example
1068
+ * ```
1069
+ * > pl.Series([1, 2, 3])
1070
+ * shape: (3,)
1071
+ * Series: '' [f64]
1072
+ * [
1073
+ * 1
1074
+ * 2
1075
+ * 3
1076
+ * ]
1077
+ * ```
1078
+ */
1079
+ <T extends JsType>(values: ArrayLike<T | null>): Series<JsToDtype<T>>;
1080
+ (values: any): Series;
1081
+ /**
1082
+ * Create a new named series
1083
+ * @param name - The name of the series
1084
+ * @param values - A set of values to include in the new Series object.
1085
+ * @example
1086
+ * ```
1087
+ * > pl.Series('foo', [1, 2, 3])
1088
+ * shape: (3,)
1089
+ * Series: 'foo' [f64]
1090
+ * [
1091
+ * 1
1092
+ * 2
1093
+ * 3
1094
+ * ]
1095
+ * ```
1096
+ */
1097
+ <T1 extends JsType, Name extends string>(name: Name, values: ArrayLike<T1 | null>): Series<JsToDtype<T1>, Name>;
1098
+ <T2 extends DataType, Name extends string>(name: Name, values: ArrayLike<DTypeToJsLoose<T2 | null>>, dtype?: T2): Series<T2, Name>;
1099
+ (name: string, values: any[], dtype?: any): Series;
1100
+ /**
1101
+ * Creates an array from an array-like object.
1102
+ * @param arrayLike — An array-like object to convert to an array.
1103
+ */
1104
+ from<T1 extends JsType>(arrayLike: ArrayLike<T1>): Series<JsToDtype<T1>>;
1105
+ from<T1>(arrayLike: ArrayLike<T1>): Series;
1106
+ from<T2 extends JsType, Name extends string>(name: Name, arrayLike: ArrayLike<T2>): Series<JsToDtype<T2>, Name>;
1107
+ from<T2>(name: string, arrayLike: ArrayLike<T2>): Series;
1108
+ /**
1109
+ * Returns a new Series from a set of elements.
1110
+ * @param items — A set of elements to include in the new Series object.
1111
+ */
1112
+ of<T3 extends JsType>(items: T3[]): Series<JsToDtype<T3>>;
1113
+ of<T3>(items: T3[]): Series;
1114
+ isSeries(arg: any): arg is Series;
1115
+ }
1116
+ export declare const Series: SeriesConstructor;