@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,785 @@
1
+ import { type DataFrame, type JoinSchemas, type Schema } from "../dataframe";
2
+ import type { Series } from "../series";
3
+ import type { Deserialize, GroupByOps, Serialize } from "../shared_traits";
4
+ import type { CsvWriterOptions, LazyCrossJoinOptions, LazyDifferentNameColumnJoinOptions, LazyOptions, LazySameNameColumnJoinOptions, SinkIpcOptions, SinkJsonOptions, SinkParquetOptions } from "../types";
5
+ import { type ColumnSelection, type ColumnsOrExpr, type ExprOrString, type Simplify, type ValueOrArray } from "../utils";
6
+ import { Expr } from "./expr";
7
+ import { type LazyGroupBy } from "./groupby";
8
+ declare const inspect: unique symbol;
9
+ /**
10
+ * Representation of a Lazy computation graph / query.
11
+ */
12
+ export interface LazyDataFrame<S extends Schema = any> extends Serialize, GroupByOps<LazyGroupBy> {
13
+ /** @ignore */
14
+ _ldf: any;
15
+ [inspect](): string;
16
+ [Symbol.toStringTag]: string;
17
+ get columns(): string[];
18
+ /**
19
+ * Cache the result once the execution of the physical plan hits this node.
20
+ */
21
+ cache(): LazyDataFrame<S>;
22
+ clone(): LazyDataFrame<S>;
23
+ /**
24
+ *
25
+ * Collect into a DataFrame.
26
+ * Note: use `fetch` if you want to run this query on the first `n` rows only.
27
+ * This can be a huge time saver in debugging queries.
28
+ * @param opts.typeCoercion -Do type coercion optimization.
29
+ * @param opts.predicatePushdown - Do predicate pushdown optimization.
30
+ * @param opts.projectionPushdown - Do projection pushdown optimization.
31
+ * @param opts.simplifyExpression - Run simplify expressions optimization.
32
+ * @param opts.noOptimization - Turn off optimizations.
33
+ * @param opts.commSubplanElim - Will try to cache branching subplans that occur on self-joins or unions.
34
+ * @param opts.commSubexprElim - Common subexpressions will be cached and reused.
35
+ * @param opts.streaming - Process the query in batches to handle larger-than-memory data.
36
+ If set to `False` (default), the entire query is processed in a single
37
+ batch.
38
+
39
+ .. warning::
40
+ Streaming mode is considered **unstable**. It may be changed
41
+ at any point without it being considered a breaking change.
42
+ * @return DataFrame
43
+ *
44
+ */
45
+ collect(opts?: LazyOptions): Promise<DataFrame<S>>;
46
+ collectSync(opts?: LazyOptions): DataFrame<S>;
47
+ /**
48
+ * A string representation of the optimized query plan.
49
+ */
50
+ describeOptimizedPlan(opts?: LazyOptions): string;
51
+ /**
52
+ * A string representation of the unoptimized query plan.
53
+ */
54
+ describePlan(): string;
55
+ /**
56
+ * Remove one or multiple columns from a DataFrame.
57
+ * @param name - column or list of columns to be removed
58
+ */
59
+ drop<U extends string>(name: U): LazyDataFrame<Simplify<Omit<S, U>>>;
60
+ drop<const U extends string[]>(names: U): LazyDataFrame<Simplify<Omit<S, U[number]>>>;
61
+ drop<U extends string, const V extends string[]>(name: U, ...names: V): LazyDataFrame<Simplify<Omit<S, U | V[number]>>>;
62
+ /**
63
+ * Drop rows with null values from this DataFrame.
64
+ * This method only drops nulls row-wise if any single value of the row is null.
65
+ */
66
+ dropNulls(column: string): LazyDataFrame<S>;
67
+ dropNulls(columns: string[]): LazyDataFrame<S>;
68
+ dropNulls(...columns: string[]): LazyDataFrame<S>;
69
+ /**
70
+ * Explode lists to long format.
71
+ */
72
+ explode(column: ExprOrString): LazyDataFrame;
73
+ explode(columns: ExprOrString[]): LazyDataFrame;
74
+ explode(column: ExprOrString, ...columns: ExprOrString[]): LazyDataFrame;
75
+ /**
76
+ * Fetch is like a collect operation, but it overwrites the number of rows read by every scan
77
+ * Note that the fetch does not guarantee the final number of rows in the DataFrame.
78
+ * Filter, join operations and a lower number of rows available in the scanned file influence the final number of rows.
79
+ * @deprecated *since 0.23.0* use `LazyFrame.collect` instead, in conjunction with a call to `head`
80
+ * @param numRows - collect 'n' number of rows from data source
81
+ * @param opts.typeCoercion -Do type coercion optimization.
82
+ * @param opts.predicatePushdown - Do predicate pushdown optimization.
83
+ * @param opts.projectionPushdown - Do projection pushdown optimization.
84
+ * @param opts.simplifyExpression - Run simplify expressions optimization.
85
+ * @param opts.commSubplanElim - Will try to cache branching subplans that occur on self-joins or unions.
86
+ * @param opts.commSubexprElim - Common subexpressions will be cached and reused.
87
+ * @param opts.streaming - Process the query in batches to handle larger-than-memory data.
88
+ If set to `False` (default), the entire query is processed in a single
89
+ batch.
90
+
91
+ .. warning::
92
+ Streaming mode is considered **unstable**. It may be changed
93
+ at any point without it being considered a breaking change.
94
+ *
95
+ */
96
+ fetch(numRows: number, opts: LazyOptions): Promise<DataFrame<S>>;
97
+ fetch(numRows?: number): Promise<DataFrame<S>>;
98
+ /** Behaves the same as fetch, but will perform the actions synchronously */
99
+ fetchSync(numRows?: number): DataFrame<S>;
100
+ fetchSync(numRows: number, opts: LazyOptions): DataFrame<S>;
101
+ /**
102
+ * Fill missing values
103
+ * @param fillValue value to fill the missing values with
104
+ */
105
+ fillNull(fillValue: string | number | Expr): LazyDataFrame<S>;
106
+ /**
107
+ * Filter the rows in the DataFrame based on a predicate expression.
108
+ * @param predicate - Expression that evaluates to a boolean Series.
109
+ * @example
110
+ * ```
111
+ * > lf = pl.DataFrame({
112
+ * > "foo": [1, 2, 3],
113
+ * > "bar": [6, 7, 8],
114
+ * > "ham": ['a', 'b', 'c']
115
+ * > }).lazy()
116
+ * > // Filter on one condition
117
+ * > lf.filter(pl.col("foo").lt(3)).collect()
118
+ * shape: (2, 3)
119
+ * ┌─────┬─────┬─────┐
120
+ * │ foo ┆ bar ┆ ham │
121
+ * │ --- ┆ --- ┆ --- │
122
+ * │ i64 ┆ i64 ┆ str │
123
+ * ╞═════╪═════╪═════╡
124
+ * │ 1 ┆ 6 ┆ a │
125
+ * ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
126
+ * │ 2 ┆ 7 ┆ b │
127
+ * └─────┴─────┴─────┘
128
+ * ```
129
+ */
130
+ filter(predicate: Expr | string): LazyDataFrame<S>;
131
+ /**
132
+ * Get the first row of the DataFrame.
133
+ */
134
+ first(): DataFrame<S>;
135
+ /**
136
+ * Start a groupby operation.
137
+ */
138
+ groupBy(by: ColumnsOrExpr, maintainOrder?: boolean): LazyGroupBy;
139
+ groupBy(by: ColumnsOrExpr, opts: {
140
+ maintainOrder: boolean;
141
+ }): LazyGroupBy;
142
+ /**
143
+ * Gets the first `n` rows of the DataFrame. You probably don't want to use this!
144
+ *
145
+ * Consider using the `fetch` operation.
146
+ * The `fetch` operation will truly load the first `n`rows lazily.
147
+ */
148
+ head(length?: number): LazyDataFrame<S>;
149
+ inner(): any;
150
+ /**
151
+ * __SQL like joins.__
152
+ * @param other - DataFrame to join with.
153
+ * @param joinOptions.on - Name(s) of the join columns in both DataFrames.
154
+ * @param joinOptions.how - Join strategy
155
+ * @param joinOptions.suffix - Suffix to append to columns with a duplicate name.
156
+ * @param joinOptions.coalesce - Coalescing behavior (merging of join columns).
157
+ * @param joinOptions.allowParallel - Allow the physical plan to optionally evaluate the computation of both DataFrames up to the join in parallel.
158
+ * @param joinOptions.forceParallel - Force the physical plan to evaluate the computation of both DataFrames up to the join in parallel.
159
+ * @see {@link LazyJoinOptions}
160
+ * @example
161
+ * ```
162
+ * >>> const df = pl.DataFrame({
163
+ * >>> foo: [1, 2, 3],
164
+ * >>> bar: [6.0, 7.0, 8.0],
165
+ * >>> ham: ['a', 'b', 'c'],
166
+ * >>> }).lazy()
167
+ * >>>
168
+ * >>> const otherDF = pl.DataFrame({
169
+ * >>> apple: ['x', 'y', 'z'],
170
+ * >>> ham: ['a', 'b', 'd'],
171
+ * >>> }).lazy();
172
+ * >>> const result = await df.join(otherDF, { on: 'ham', how: 'inner' }).collect();
173
+ * shape: (2, 4)
174
+ * ╭─────┬─────┬─────┬───────╮
175
+ * │ foo ┆ bar ┆ ham ┆ apple │
176
+ * │ --- ┆ --- ┆ --- ┆ --- │
177
+ * │ i64 ┆ f64 ┆ str ┆ str │
178
+ * ╞═════╪═════╪═════╪═══════╡
179
+ * │ 1 ┆ 6 ┆ "a" ┆ "x" │
180
+ * ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌┤
181
+ * │ 2 ┆ 7 ┆ "b" ┆ "y" │
182
+ * ╰─────┴─────┴─────┴───────╯
183
+ * ```
184
+ */
185
+ join<S2 extends Schema, const Opts extends LazySameNameColumnJoinOptions<Extract<keyof S, string>, Extract<keyof S2, string>>>(other: LazyDataFrame<S2>, joinOptions: Opts & LazySameNameColumnJoinOptions): LazyDataFrame<JoinSchemas<S, S2, Opts>>;
186
+ /**
187
+ * __SQL like joins with different names for left and right dataframes.__
188
+ * @param other - DataFrame to join with.
189
+ * @param joinOptions.leftOn - Name(s) of the left join column(s).
190
+ * @param joinOptions.rightOn - Name(s) of the right join column(s).
191
+ * @param joinOptions.how - Join strategy
192
+ * @param joinOptions.suffix - Suffix to append to columns with a duplicate name.
193
+ * @param joinOptions.coalesce - Coalescing behavior (merging of join columns).
194
+ * @param joinOptions.allowParallel - Allow the physical plan to optionally evaluate the computation of both DataFrames up to the join in parallel.
195
+ * @param joinOptions.forceParallel - Force the physical plan to evaluate the computation of both DataFrames up to the join in parallel.
196
+ * @see {@link LazyJoinOptions}
197
+ * @example
198
+ * ```
199
+ * >>> const df = pl.DataFrame({
200
+ * >>> foo: [1, 2, 3],
201
+ * >>> bar: [6.0, 7.0, 8.0],
202
+ * >>> ham: ['a', 'b', 'c'],
203
+ * >>> }).lazy()
204
+ * >>>
205
+ * >>> const otherDF = pl.DataFrame({
206
+ * >>> apple: ['x', 'y', 'z'],
207
+ * >>> ham: ['a', 'b', 'd'],
208
+ * >>> }).lazy();
209
+ * >>> const result = await df.join(otherDF, { leftOn: 'ham', rightOn: 'ham', how: 'inner' }).collect();
210
+ * shape: (2, 4)
211
+ * ╭─────┬─────┬─────┬───────╮
212
+ * │ foo ┆ bar ┆ ham ┆ apple │
213
+ * │ --- ┆ --- ┆ --- ┆ --- │
214
+ * │ i64 ┆ f64 ┆ str ┆ str │
215
+ * ╞═════╪═════╪═════╪═══════╡
216
+ * │ 1 ┆ 6 ┆ "a" ┆ "x" │
217
+ * ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌┤
218
+ * │ 2 ┆ 7 ┆ "b" ┆ "y" │
219
+ * ╰─────┴─────┴─────┴───────╯
220
+ * ```
221
+ */
222
+ join<S2 extends Schema, const Opts extends LazyDifferentNameColumnJoinOptions<Extract<keyof S, string>, Extract<keyof S2, string>>>(other: LazyDataFrame<S2>, joinOptions: Opts & LazyDifferentNameColumnJoinOptions): LazyDataFrame<JoinSchemas<S, S2, Opts>>;
223
+ /**
224
+ * __SQL like cross joins.__
225
+ * @param other - DataFrame to join with.
226
+ * @param joinOptions.how - Join strategy {'inner', 'left', 'right', 'full', 'semi', 'anti', 'cross'}
227
+ * @param joinOptions.suffix - Suffix to append to columns with a duplicate name.
228
+ * @param joinOptions.coalesce - Coalescing behavior (merging of join columns). default: undefined
229
+ * - **undefined** - *(Default)* Coalesce unless `how='full'` is specified.
230
+ * - **true** - Always coalesce join columns.
231
+ * - **false** - Never coalesce join columns.
232
+ * @param joinOptions.validate - Checks if join is of specified type. default: m:m
233
+ * valid options: {'m:m', 'm:1', '1:m', '1:1'}
234
+ * - **m:m** - *(Default)* Many-to-many (default). Does not result in checks.
235
+ * - **1:1** - One-to-one. Checks if join keys are unique in both left and right datasets.
236
+ * - **1:m** - One-to-many. Checks if join keys are unique in left dataset.
237
+ * - **m:1** - Many-to-one. Check if join keys are unique in right dataset.
238
+ * @param joinOptions.allowParallel - Allow the physical plan to optionally evaluate the computation of both DataFrames up to the join in parallel.
239
+ * @param joinOptions.forceParallel - Force the physical plan to evaluate the computation of both DataFrames up to the join in parallel.
240
+ * @see {@link LazyJoinOptions}
241
+ * @example
242
+ * ```
243
+ * >>> const df = pl.DataFrame({
244
+ * >>> foo: [1, 2],
245
+ * >>> bar: [6.0, 7.0],
246
+ * >>> ham: ['a', 'b'],
247
+ * >>> }).lazy()
248
+ * >>>
249
+ * >>> const otherDF = pl.DataFrame({
250
+ * >>> apple: ['x', 'y'],
251
+ * >>> ham: ['a', 'b'],
252
+ * >>> }).lazy();
253
+ * >>> const result = await df.join(otherDF, { how: 'cross' }).collect();
254
+ * shape: (4, 5)
255
+ * ╭─────┬─────┬─────┬───────┬───────────╮
256
+ * │ foo ┆ bar ┆ ham ┆ apple ┆ ham_right │
257
+ * │ --- ┆ --- ┆ --- ┆ --- ┆ --- │
258
+ * │ f64 ┆ f64 ┆ str ┆ str ┆ str │
259
+ * ╞═════╪═════╪═════╪═══════╪═══════════╡
260
+ * │ 1.0 ┆ 6.0 ┆ a ┆ x ┆ a │
261
+ * │ 1.0 ┆ 6.0 ┆ a ┆ y ┆ b │
262
+ * │ 2.0 ┆ 7.0 ┆ b ┆ x ┆ a │
263
+ * │ 2.0 ┆ 7.0 ┆ b ┆ y ┆ b │
264
+ * ╰─────┴─────┴─────┴───────┴───────────╯
265
+ * ```
266
+ */
267
+ join<S2 extends Schema, const Opts extends LazyCrossJoinOptions>(other: LazyDataFrame<S2>, joinOptions: Opts & LazyCrossJoinOptions): LazyDataFrame<JoinSchemas<S, S2, Opts>>;
268
+ /**
269
+ * Perform an asof join. This is similar to a left-join except that we
270
+ * match on nearest key rather than equal keys.
271
+ *
272
+ * Both DataFrames must be sorted by the asof_join key.
273
+ *
274
+ For each row in the left DataFrame:
275
+
276
+ - A "backward" search selects the last row in the right DataFrame whose
277
+ 'on' key is less than or equal to the left's key.
278
+
279
+ - A "forward" search selects the first row in the right DataFrame whose
280
+ 'on' key is greater than or equal to the left's key.
281
+
282
+ - A "nearest" search selects the last row in the right DataFrame whose value
283
+ is nearest to the left's key. String keys are not currently supported for a
284
+ nearest search.
285
+
286
+ The default is "backward".
287
+
288
+ Parameters
289
+ ----------
290
+ @param other DataFrame to join with.
291
+ @param options.leftOn Join column of the left DataFrame.
292
+ @param options.rightOn Join column of the right DataFrame.
293
+ @param options.on Join column of both DataFrames. If set, `leftOn` and `rightOn` should be undefined.
294
+ @param options.byLeft join on these columns before doing asof join
295
+ @param options.byRight join on these columns before doing asof join
296
+ @param options.strategy One of {'forward', 'backward', 'nearest'}
297
+ @param options.suffix Suffix to append to columns with a duplicate name.
298
+ @param options.tolerance
299
+ Numeric tolerance. By setting this the join will only be done if the near keys are within this distance.
300
+ If an asof join is done on columns of dtype "Date", "Datetime" you
301
+ use the following string language:
302
+
303
+ - 1ns *(1 nanosecond)*
304
+ - 1us *(1 microsecond)*
305
+ - 1ms *(1 millisecond)*
306
+ - 1s *(1 second)*
307
+ - 1m *(1 minute)*
308
+ - 1h *(1 hour)*
309
+ - 1d *(1 day)*
310
+ - 1w *(1 week)*
311
+ - 1mo *(1 calendar month)*
312
+ - 1y *(1 calendar year)*
313
+ - 1i *(1 index count)*
314
+
315
+ Or combine them:
316
+ - "3d12h4m25s" # 3 days, 12 hours, 4 minutes, and 25 seconds
317
+ @param options.allowParallel Allow the physical plan to optionally evaluate the computation of both DataFrames up to the join in parallel.
318
+ @param options.forceParallel Force the physical plan to evaluate the computation of both DataFrames up to the join in parallel.
319
+ @param options.checkSortedness
320
+ Check the sortedness of the asof keys. If the keys are not sorted Polars
321
+ will error, or in case of 'by' argument raise a warning. This might become
322
+ a hard error in the future.
323
+
324
+
325
+ @example
326
+ ```
327
+ >const gdp = pl.DataFrame({
328
+ ... date: [
329
+ ... new Date('2016-01-01'),
330
+ ... new Date('2017-01-01'),
331
+ ... new Date('2018-01-01'),
332
+ ... new Date('2019-01-01'),
333
+ ... ], // note record date: Jan 1st (sorted!)
334
+ ... gdp: [4164, 4411, 4566, 4696],
335
+ ... })
336
+ >const population = pl.DataFrame({
337
+ ... date: [
338
+ ... new Date('2016-05-12'),
339
+ ... new Date('2017-05-12'),
340
+ ... new Date('2018-05-12'),
341
+ ... new Date('2019-05-12'),
342
+ ... ], // note record date: May 12th (sorted!)
343
+ ... "population": [82.19, 82.66, 83.12, 83.52],
344
+ ... })
345
+ >population.joinAsof(
346
+ ... gdp,
347
+ ... {leftOn:"date", rightOn:"date", strategy:"backward"}
348
+ ... )
349
+ shape: (4, 3)
350
+ ┌─────────────────────┬────────────┬──────┐
351
+ │ date ┆ population ┆ gdp │
352
+ │ --- ┆ --- ┆ --- │
353
+ │ datetime[μs] ┆ f64 ┆ i64 │
354
+ ╞═════════════════════╪════════════╪══════╡
355
+ │ 2016-05-12 00:00:00 ┆ 82.19 ┆ 4164 │
356
+ ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┤
357
+ │ 2017-05-12 00:00:00 ┆ 82.66 ┆ 4411 │
358
+ ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┤
359
+ │ 2018-05-12 00:00:00 ┆ 83.12 ┆ 4566 │
360
+ ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┤
361
+ │ 2019-05-12 00:00:00 ┆ 83.52 ┆ 4696 │
362
+ └─────────────────────┴────────────┴──────┘
363
+ ```
364
+ */
365
+ joinAsof(other: LazyDataFrame, options: {
366
+ leftOn?: string;
367
+ rightOn?: string;
368
+ on?: string;
369
+ byLeft?: string | string[];
370
+ byRight?: string | string[];
371
+ by?: string | string[];
372
+ strategy?: "backward" | "forward" | "nearest";
373
+ suffix?: string;
374
+ tolerance?: number | string;
375
+ allowParallel?: boolean;
376
+ forceParallel?: boolean;
377
+ checkSortedness?: boolean;
378
+ }): LazyDataFrame;
379
+ /**
380
+ * Get the last row of the DataFrame.
381
+ */
382
+ last(): LazyDataFrame<S>;
383
+ /**
384
+ * @see {@link head}
385
+ */
386
+ limit(n?: number): LazyDataFrame<S>;
387
+ /**
388
+ * @see {@link DataFrame.max}
389
+ */
390
+ max(): LazyDataFrame<S>;
391
+ /**
392
+ * @see {@link DataFrame.mean}
393
+ */
394
+ mean(): LazyDataFrame<S>;
395
+ /**
396
+ * @see {@link DataFrame.median}
397
+ */
398
+ median(): LazyDataFrame<S>;
399
+ /**
400
+ * @see {@link DataFrame.unpivot}
401
+ * @deprecated use `LazyFrame.unpivot` instead
402
+ */
403
+ melt(idVars: ColumnSelection, valueVars: ColumnSelection): LazyDataFrame;
404
+ /**
405
+ * @see {@link DataFrame.unpivot}
406
+ */
407
+ unpivot(idVars: ColumnSelection, valueVars: ColumnSelection, options?: {
408
+ variableName?: string | null;
409
+ valueName?: string | null;
410
+ }): LazyDataFrame;
411
+ /**
412
+ * @see {@link DataFrame.min}
413
+ */
414
+ min(): LazyDataFrame<S>;
415
+ /**
416
+ * @see {@link DataFrame.quantile}
417
+ */
418
+ quantile(quantile: number): LazyDataFrame<S>;
419
+ /**
420
+ * @see {@link DataFrame.rename}
421
+ */
422
+ rename<const U extends Partial<Record<keyof S, string>>>(mapping: U): LazyDataFrame<{
423
+ [K in keyof S as U[K] extends string ? U[K] : K]: S[K];
424
+ }>;
425
+ rename(mapping: Record<string, string>): LazyDataFrame;
426
+ /**
427
+ * Reverse the DataFrame.
428
+ */
429
+ reverse(): LazyDataFrame<S>;
430
+ /**
431
+ * @see {@link DataFrame.select}
432
+ */
433
+ select<U extends keyof S>(...columns: U[]): LazyDataFrame<{
434
+ [P in U]: S[P];
435
+ }>;
436
+ select(column: ExprOrString | Series): LazyDataFrame;
437
+ select(columns: (ExprOrString | Series)[]): LazyDataFrame;
438
+ select(...columns: (ExprOrString | Series)[]): LazyDataFrame;
439
+ /**
440
+ * @see {@link DataFrame.shift}
441
+ */
442
+ shift(periods: number): LazyDataFrame<S>;
443
+ shift(opts: {
444
+ periods: number;
445
+ }): LazyDataFrame<S>;
446
+ /**
447
+ * @see {@link DataFrame.shiftAndFill}
448
+ */
449
+ shiftAndFill(n: number, fillValue: number): LazyDataFrame<S>;
450
+ shiftAndFill(opts: {
451
+ n: number;
452
+ fillValue: number;
453
+ }): LazyDataFrame<S>;
454
+ /**
455
+ * @see {@link DataFrame.slice}
456
+ */
457
+ slice(offset: number, length: number): LazyDataFrame<S>;
458
+ slice(opts: {
459
+ offset: number;
460
+ length: number;
461
+ }): LazyDataFrame<S>;
462
+ /**
463
+ * @see {@link DataFrame.sort}
464
+ */
465
+ sort(by: ColumnsOrExpr, descending?: ValueOrArray<boolean>, nullsLast?: boolean, maintainOrder?: boolean): LazyDataFrame<S>;
466
+ sort(opts: {
467
+ by: ColumnsOrExpr;
468
+ descending?: ValueOrArray<boolean>;
469
+ nullsLast?: boolean;
470
+ maintainOrder?: boolean;
471
+ }): LazyDataFrame<S>;
472
+ /**
473
+ * @see {@link DataFrame.std}
474
+ */
475
+ std(): LazyDataFrame<S>;
476
+ /**
477
+ * Aggregate the columns in the DataFrame to their sum value.
478
+ */
479
+ sum(): LazyDataFrame<S>;
480
+ /**
481
+ * Get the last `n` rows of the DataFrame.
482
+ * @see {@link DataFrame.tail}
483
+ */
484
+ tail(length?: number): LazyDataFrame<S>;
485
+ /**
486
+ * compatibility with `JSON.stringify`
487
+ */
488
+ toJSON(): string;
489
+ /**
490
+ * Drop duplicate rows from this DataFrame.
491
+ * Note that this fails if there is a column of type `List` in the DataFrame.
492
+ * @param subset Column name(s), selector(s) to consider when identifying duplicate rows. If set to `None` (default), all columns are considered.
493
+ * @param keep : 'first', 'last', 'any', 'none'
494
+ * Which of the duplicate rows to keep.
495
+ * 'any': Defaut, does not give any guarantee of which row is kept. This allows more optimizations.
496
+ * 'none': Don't keep duplicate rows.
497
+ * 'first': Keep the first unique row.
498
+ * 'last': Keep the last unique row.
499
+ * @param maintainOrder Keep the same order as the original DataFrame. This is more expensive to compute. Default: false
500
+ * @returns LazyDataFrame with unique rows.
501
+ * @example
502
+ * const ldf = pl.DataFrame({
503
+ foo: [1, 2, 2, 3],
504
+ bar: [1, 2, 2, 4],
505
+ ham: ["a", "d", "d", "c"],
506
+ }).lazy();
507
+ > ldf.unique().collectSync();
508
+ By default, all columns are considered when determining which rows are unique:
509
+ shape: (3, 3)
510
+ ┌─────┬─────┬─────┐
511
+ │ foo ┆ bar ┆ ham │
512
+ │ --- ┆ --- ┆ --- │
513
+ │ f64 ┆ f64 ┆ str │
514
+ ╞═════╪═════╪═════╡
515
+ │ 3.0 ┆ 4.0 ┆ c │
516
+ │ 1.0 ┆ 1.0 ┆ a │
517
+ │ 2.0 ┆ 2.0 ┆ d │
518
+ └─────┴─────┴─────┘
519
+ > ldf.unique("foo").collectSync();
520
+ shape: (3, 3)
521
+ ┌─────┬─────┬─────┐
522
+ │ foo ┆ bar ┆ ham │
523
+ │ --- ┆ --- ┆ --- │
524
+ │ f64 ┆ f64 ┆ str │
525
+ ╞═════╪═════╪═════╡
526
+ │ 3.0 ┆ 4.0 ┆ c │
527
+ │ 1.0 ┆ 1.0 ┆ a │
528
+ │ 2.0 ┆ 2.0 ┆ d │
529
+ └─────┴─────┴─────┘
530
+ > ldf.unique(["foo", "ham"], "first", true).collectSync(); or df.unique({ subset: ["foo", "ham"], keep: "first", maintainOrder: true }).collectSync();
531
+ shape: (3, 3)
532
+ ┌─────┬─────┬─────┐
533
+ │ foo ┆ bar ┆ ham │
534
+ │ --- ┆ --- ┆ --- │
535
+ │ f64 ┆ f64 ┆ str │
536
+ ╞═════╪═════╪═════╡
537
+ │ 1.0 ┆ 1.0 ┆ a │
538
+ │ 2.0 ┆ 2.0 ┆ d │
539
+ │ 3.0 ┆ 4.0 ┆ c │
540
+ └─────┴─────┴─────┘
541
+ */
542
+ unique(subset?: ColumnSelection, keep?: "first" | "last" | "any" | "none", maintainOrder?: boolean): LazyDataFrame<S>;
543
+ unique(opts: {
544
+ subset?: ColumnSelection;
545
+ keep?: "first" | "last" | "any" | "none";
546
+ maintainOrder?: boolean;
547
+ }): LazyDataFrame<S>;
548
+ /**
549
+ * Aggregate the columns in the DataFrame to their variance value.
550
+ */
551
+ var(): LazyDataFrame<S>;
552
+ /**
553
+ * Add or overwrite column in a DataFrame.
554
+ * @param expr - Expression that evaluates to column.
555
+ */
556
+ withColumn(expr: Expr | Series): LazyDataFrame;
557
+ /**
558
+ * Add or overwrite multiple columns in a DataFrame.
559
+ * @param exprs - List of Expressions that evaluate to columns.
560
+ *
561
+ */
562
+ withColumns(...exprs: (Expr | Series)[]): LazyDataFrame;
563
+ withColumnRenamed<Existing extends keyof S, New extends string>(existing: Existing, replacement: New): LazyDataFrame<{
564
+ [K in keyof S as K extends Existing ? New : K]: S[K];
565
+ }>;
566
+ withColumnRenamed(existing: string, replacement: string): LazyDataFrame;
567
+ /**
568
+ * Add a column at index 0 that counts the rows.
569
+ * @see {@link DataFrame.withRowCount}
570
+ * @deprecated *since 0.23.0 use withRowIndex instead
571
+ */
572
+ withRowCount(): LazyDataFrame;
573
+ /**
574
+ * Add a row index as the first column in the DataFrame.
575
+ * @param name Name of the index column.
576
+ * @param offset Start the index at this offset. Cannot be negative.
577
+ * @example
578
+ *
579
+ * >>> ldf = pl.DataFrame(
580
+ ... {
581
+ ... "a": [1, 3, 5],
582
+ ... "b": [2, 4, 6],
583
+ ... }
584
+ ... ).lazy();
585
+ >>> ldf.withRowIndex().collectSync();
586
+ shape: (3, 3)
587
+ ┌───────┬─────┬─────┐
588
+ │ index ┆ a ┆ b │
589
+ │ --- ┆ --- ┆ --- │
590
+ │ u32 ┆ i64 ┆ i64 │
591
+ ╞═══════╪═════╪═════╡
592
+ │ 0 ┆ 1 ┆ 2 │
593
+ │ 1 ┆ 3 ┆ 4 │
594
+ │ 2 ┆ 5 ┆ 6 │
595
+ └───────┴─────┴─────┘
596
+ >>> ldf.withRowIndex("id", offset=1000).collectSync();
597
+ shape: (3, 3)
598
+ ┌──────┬─────┬─────┐
599
+ │ id ┆ a ┆ b │
600
+ │ --- ┆ --- ┆ --- │
601
+ │ u32 ┆ i64 ┆ i64 │
602
+ ╞══════╪═════╪═════╡
603
+ │ 1000 ┆ 1 ┆ 2 │
604
+ │ 1001 ┆ 3 ┆ 4 │
605
+ │ 1002 ┆ 5 ┆ 6 │
606
+ └──────┴─────┴─────┘
607
+ */
608
+ withRowIndex(name?: string, offset?: number): LazyDataFrame;
609
+ /***
610
+ *
611
+ * Evaluate the query in streaming mode and write to a CSV file.
612
+
613
+ .. warning::
614
+ Streaming mode is considered **unstable**. It may be changed
615
+ at any point without it being considered a breaking change.
616
+
617
+ This allows streaming results that are larger than RAM to be written to disk.
618
+
619
+ Parameters
620
+ ----------
621
+ @param path - File path to which the file should be written.
622
+ @param options.includeBom - Whether to include UTF-8 BOM in the CSV output.
623
+ @param options.includeHeader - Whether to include header in the CSV output.
624
+ @param options.separator - Separate CSV fields with this symbol.
625
+ @param options.lineTerminator - String used to end each row.
626
+ @param options.quoteChar - Byte to use as quoting character. Default: '"'
627
+ @param options.batchSize - Number of rows that will be processed per thread. Default - 1024
628
+ @param options.datetimeFormat - A format string, with the specifiers defined by the
629
+ `chrono <https://docs.rs/chrono/latest/chrono/format/strftime/index.html>`_
630
+ Rust crate. If no format specified, the default fractional-second
631
+ precision is inferred from the maximum timeunit found in the frame's
632
+ Datetime cols (if any).
633
+ @param options.dateFormat - A format string, with the specifiers defined by the
634
+ `chrono <https://docs.rs/chrono/latest/chrono/format/strftime/index.html>`_
635
+ Rust crate.
636
+ @param options.timeFormat A format string, with the specifiers defined by the
637
+ `chrono <https://docs.rs/chrono/latest/chrono/format/strftime/index.html>`_
638
+ Rust crate.
639
+ @param options.floatPrecision - Number of decimal places to write, applied to both `Float32` and `Float64` datatypes.
640
+ @param options.nullValue - A string representing null values (defaulting to the empty string).
641
+ @param options.maintainOrder - Maintain the order in which data is processed.
642
+ Setting this to `False` will be slightly faster.
643
+ @return DataFrame
644
+ Examples
645
+ --------
646
+ >>> const lf = pl.scanCsv("/path/to/my_larger_than_ram_file.csv")
647
+ >>> lf.sinkCsv("out.csv").collect()
648
+ */
649
+ sinkCSV(path: string, options?: CsvWriterOptions): LazyDataFrame;
650
+ /***
651
+ *
652
+ * Evaluate the query in streaming mode and write to a Parquet file.
653
+
654
+ This allows streaming results that are larger than RAM to be written to disk.
655
+
656
+ Parameters
657
+ ----------
658
+ @param path - File path to which the file should be written.
659
+ @param options.compression : {'lz4', 'uncompressed', 'snappy', 'gzip', 'lzo', 'brotli', 'zstd'}
660
+ Choose "zstd" for good compression performance. (default)
661
+ Choose "lz4" for fast compression/decompression.
662
+ Choose "snappy" for more backwards compatibility guarantees
663
+ when you deal with older parquet readers.
664
+ @param options.compressionLevel - The level of compression to use. Higher compression means smaller files on disk.
665
+ - "gzip" : min-level: 0, max-level: 10.
666
+ - "brotli" : min-level: 0, max-level: 11.
667
+ - "zstd" : min-level: 1, max-level: 22.
668
+ @param options.statistics - Write statistics to the parquet headers. This requires extra compute. Default - false
669
+ @param options.rowGroupSize - Size of the row groups in number of rows.
670
+ If None (default), the chunks of the `DataFrame` are
671
+ used. Writing in smaller chunks may reduce memory pressure and improve
672
+ writing speeds.
673
+ @param options.dataPagesizeLimit - Size limit of individual data pages.
674
+ If not set defaults to 1024 * 1024 bytes
675
+ @param options.maintainOrder - Maintain the order in which data is processed. Default -> true
676
+ Setting this to `False` will be slightly faster.
677
+ @param options.typeCoercion - Do type coercion optimization. Default -> true
678
+ @param options.predicatePushdown - Do predicate pushdown optimization. Default -> true
679
+ @param options.projectionPushdown - Do projection pushdown optimization. Default -> true
680
+ @param options.simplifyExpression - Run simplify expressions optimization. Default -> true
681
+ @param options.slicePushdown - Slice pushdown optimization. Default -> true
682
+ @param options.noOptimization - Turn off (certain) optimizations. Default -> false
683
+ @param options.cloudOptions - Options that indicate how to connect to a cloud provider.
684
+ If the cloud provider is not supported by Polars, the storage options are passed to `fsspec.open()`.
685
+
686
+ The cloud providers currently supported are AWS, GCP, and Azure.
687
+ See supported keys here:
688
+
689
+ * `aws <https://docs.rs/object_store/latest/object_store/aws/enum.AmazonS3ConfigKey.html>`_
690
+ * `gcp <https://docs.rs/object_store/latest/object_store/gcp/enum.GoogleConfigKey.html>`_
691
+ * `azure <https://docs.rs/object_store/latest/object_store/azure/enum.AzureConfigKey.html>`_
692
+
693
+ If `cloudOptions` is not provided, Polars will try to infer the information from environment variables.
694
+ @return DataFrame
695
+ Examples
696
+ --------
697
+ >>> const lf = pl.scanCsv("/path/to/my_larger_than_ram_file.csv") # doctest: +SKIP
698
+ >>> lf.sinkParquet("out.parquet").collect() # doctest: +SKIP
699
+ */
700
+ sinkParquet(path: string, options?: SinkParquetOptions): LazyDataFrame;
701
+ /**
702
+ *
703
+ * Evaluate the query in streaming mode and write to an NDJSON file.
704
+ * This allows streaming results that are larger than RAM to be written to disk.
705
+ *
706
+ * Parameters
707
+ @param path - File path to which the file should be written.
708
+ @param options.maintainOrder - Maintain the order in which data is processed. Default -> true
709
+ Setting this to `False` will be slightly faster.
710
+ @param options.mkdir - Recursively create all the directories in the path. Default -> false
711
+ @param options.retries - Number of retries if accessing a cloud instance fails. Default = 2
712
+ @param options.syncOnClose - { None, 'data', 'all' } Default -> 'all'
713
+ Sync to disk when before closing a file.
714
+
715
+ * `None` does not sync.
716
+ * `data` syncs the file contents.
717
+ * `all` syncs the file contents and metadata.
718
+ @param options.cloudOptions - Options that indicate how to connect to a cloud provider.
719
+ If the cloud provider is not supported by Polars, the storage options are passed to `fsspec.open()`.
720
+
721
+ The cloud providers currently supported are AWS, GCP, and Azure.
722
+ See supported keys here:
723
+
724
+ * `aws <https://docs.rs/object_store/latest/object_store/aws/enum.AmazonS3ConfigKey.html>`_
725
+ * `gcp <https://docs.rs/object_store/latest/object_store/gcp/enum.GoogleConfigKey.html>`_
726
+ * `azure <https://docs.rs/object_store/latest/object_store/azure/enum.AzureConfigKey.html>`_
727
+
728
+ If `cloudOptions` is not provided, Polars will try to infer the information from environment variables.
729
+ @return DataFrame
730
+ Examples
731
+ --------
732
+ >>> const lf = pl.scanCsv("/path/to/my_larger_than_ram_file.csv") # doctest: +SKIP
733
+ >>> lf.sinkNdJson("out.ndjson").collect()
734
+ */
735
+ sinkNdJson(path: string, options?: SinkJsonOptions): LazyDataFrame;
736
+ /**
737
+ *
738
+ * Evaluate the query in streaming mode and write to an IPC file.
739
+ * This allows streaming results that are larger than RAM to be written to disk.
740
+ *
741
+ * Parameters
742
+ @param path - File path to which the file should be written.
743
+ @param options.compression : {'uncompressed', 'lz4', 'zstd'}
744
+ Choose "zstd" for good compression performance.
745
+ Choose "lz4" for fast compression/decompression.
746
+ @param options.compatLevel : { 'newest', 'oldest' } Default -> newest
747
+ Use a specific compatibility level when exporting Polars' internal data structures.
748
+ @param options.maintainOrder - Maintain the order in which data is processed. Default -> true
749
+ Setting this to `False` will be slightly faster.
750
+ @param options.mkdir - Recursively create all the directories in the path. Default -> false
751
+ @param options.retries - Number of retries if accessing a cloud instance fails. Default = 2
752
+ @param options.syncOnClose - { None, 'data', 'all' } Default -> 'all'
753
+ Sync to disk when before closing a file.
754
+
755
+ * `None` does not sync.
756
+ * `data` syncs the file contents.
757
+ * `all` syncs the file contents and metadata.
758
+ @param options.cloudOptions - Options that indicate how to connect to a cloud provider.
759
+ If the cloud provider is not supported by Polars, the storage options are passed to `fsspec.open()`.
760
+
761
+ The cloud providers currently supported are AWS, GCP, and Azure.
762
+ See supported keys here:
763
+
764
+ * `aws <https://docs.rs/object_store/latest/object_store/aws/enum.AmazonS3ConfigKey.html>`_
765
+ * `gcp <https://docs.rs/object_store/latest/object_store/gcp/enum.GoogleConfigKey.html>`_
766
+ * `azure <https://docs.rs/object_store/latest/object_store/azure/enum.AzureConfigKey.html>`_
767
+
768
+ If `cloudOptions` is not provided, Polars will try to infer the information from environment variables.
769
+ @return DataFrame
770
+ Examples
771
+ --------
772
+ >>> const lf = pl.scanCsv("/path/to/my_larger_than_ram_file.csv") # doctest: +SKIP
773
+ >>> lf.sinkIpc("out.arrow").collect()
774
+ */
775
+ sinkIpc(path: string, options?: SinkIpcOptions): LazyDataFrame;
776
+ }
777
+ /** @ignore */
778
+ export declare const _LazyDataFrame: (_ldf: any) => LazyDataFrame;
779
+ export interface LazyDataFrameConstructor extends Deserialize<LazyDataFrame> {
780
+ fromExternal(external: any): LazyDataFrame;
781
+ isLazyDataFrame(arg: any): arg is LazyDataFrame;
782
+ }
783
+ /** @ignore */
784
+ export declare const LazyDataFrame: LazyDataFrameConstructor;
785
+ export {};