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