polars-runtime-compat 1.34.0b3__cp39-abi3-macosx_11_0_arm64.whl → 1.34.0b4__cp39-abi3-macosx_11_0_arm64.whl

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.

Potentially problematic release.


This version of polars-runtime-compat might be problematic. Click here for more details.

Files changed (203) hide show
  1. _polars_runtime_compat/_polars_runtime_compat.abi3.so +0 -0
  2. {polars_runtime_compat-1.34.0b3.dist-info → polars_runtime_compat-1.34.0b4.dist-info}/METADATA +1 -1
  3. polars_runtime_compat-1.34.0b4.dist-info/RECORD +6 -0
  4. polars/__init__.py +0 -528
  5. polars/_cpu_check.py +0 -265
  6. polars/_dependencies.py +0 -355
  7. polars/_plr.py +0 -99
  8. polars/_plr.pyi +0 -2496
  9. polars/_reexport.py +0 -23
  10. polars/_typing.py +0 -478
  11. polars/_utils/__init__.py +0 -37
  12. polars/_utils/async_.py +0 -102
  13. polars/_utils/cache.py +0 -176
  14. polars/_utils/cloud.py +0 -40
  15. polars/_utils/constants.py +0 -29
  16. polars/_utils/construction/__init__.py +0 -46
  17. polars/_utils/construction/dataframe.py +0 -1397
  18. polars/_utils/construction/other.py +0 -72
  19. polars/_utils/construction/series.py +0 -560
  20. polars/_utils/construction/utils.py +0 -118
  21. polars/_utils/convert.py +0 -224
  22. polars/_utils/deprecation.py +0 -406
  23. polars/_utils/getitem.py +0 -457
  24. polars/_utils/logging.py +0 -11
  25. polars/_utils/nest_asyncio.py +0 -264
  26. polars/_utils/parquet.py +0 -15
  27. polars/_utils/parse/__init__.py +0 -12
  28. polars/_utils/parse/expr.py +0 -242
  29. polars/_utils/polars_version.py +0 -19
  30. polars/_utils/pycapsule.py +0 -53
  31. polars/_utils/scan.py +0 -27
  32. polars/_utils/serde.py +0 -63
  33. polars/_utils/slice.py +0 -215
  34. polars/_utils/udfs.py +0 -1251
  35. polars/_utils/unstable.py +0 -63
  36. polars/_utils/various.py +0 -782
  37. polars/_utils/wrap.py +0 -25
  38. polars/api.py +0 -370
  39. polars/catalog/__init__.py +0 -0
  40. polars/catalog/unity/__init__.py +0 -19
  41. polars/catalog/unity/client.py +0 -733
  42. polars/catalog/unity/models.py +0 -152
  43. polars/config.py +0 -1571
  44. polars/convert/__init__.py +0 -25
  45. polars/convert/general.py +0 -1046
  46. polars/convert/normalize.py +0 -261
  47. polars/dataframe/__init__.py +0 -5
  48. polars/dataframe/_html.py +0 -186
  49. polars/dataframe/frame.py +0 -12582
  50. polars/dataframe/group_by.py +0 -1067
  51. polars/dataframe/plotting.py +0 -257
  52. polars/datatype_expr/__init__.py +0 -5
  53. polars/datatype_expr/array.py +0 -56
  54. polars/datatype_expr/datatype_expr.py +0 -304
  55. polars/datatype_expr/list.py +0 -18
  56. polars/datatype_expr/struct.py +0 -69
  57. polars/datatypes/__init__.py +0 -122
  58. polars/datatypes/_parse.py +0 -195
  59. polars/datatypes/_utils.py +0 -48
  60. polars/datatypes/classes.py +0 -1213
  61. polars/datatypes/constants.py +0 -11
  62. polars/datatypes/constructor.py +0 -172
  63. polars/datatypes/convert.py +0 -366
  64. polars/datatypes/group.py +0 -130
  65. polars/exceptions.py +0 -230
  66. polars/expr/__init__.py +0 -7
  67. polars/expr/array.py +0 -964
  68. polars/expr/binary.py +0 -346
  69. polars/expr/categorical.py +0 -306
  70. polars/expr/datetime.py +0 -2620
  71. polars/expr/expr.py +0 -11272
  72. polars/expr/list.py +0 -1408
  73. polars/expr/meta.py +0 -444
  74. polars/expr/name.py +0 -321
  75. polars/expr/string.py +0 -3045
  76. polars/expr/struct.py +0 -357
  77. polars/expr/whenthen.py +0 -185
  78. polars/functions/__init__.py +0 -193
  79. polars/functions/aggregation/__init__.py +0 -33
  80. polars/functions/aggregation/horizontal.py +0 -298
  81. polars/functions/aggregation/vertical.py +0 -341
  82. polars/functions/as_datatype.py +0 -848
  83. polars/functions/business.py +0 -138
  84. polars/functions/col.py +0 -384
  85. polars/functions/datatype.py +0 -121
  86. polars/functions/eager.py +0 -524
  87. polars/functions/escape_regex.py +0 -29
  88. polars/functions/lazy.py +0 -2751
  89. polars/functions/len.py +0 -68
  90. polars/functions/lit.py +0 -210
  91. polars/functions/random.py +0 -22
  92. polars/functions/range/__init__.py +0 -19
  93. polars/functions/range/_utils.py +0 -15
  94. polars/functions/range/date_range.py +0 -303
  95. polars/functions/range/datetime_range.py +0 -370
  96. polars/functions/range/int_range.py +0 -348
  97. polars/functions/range/linear_space.py +0 -311
  98. polars/functions/range/time_range.py +0 -287
  99. polars/functions/repeat.py +0 -301
  100. polars/functions/whenthen.py +0 -353
  101. polars/interchange/__init__.py +0 -10
  102. polars/interchange/buffer.py +0 -77
  103. polars/interchange/column.py +0 -190
  104. polars/interchange/dataframe.py +0 -230
  105. polars/interchange/from_dataframe.py +0 -328
  106. polars/interchange/protocol.py +0 -303
  107. polars/interchange/utils.py +0 -170
  108. polars/io/__init__.py +0 -64
  109. polars/io/_utils.py +0 -317
  110. polars/io/avro.py +0 -49
  111. polars/io/clipboard.py +0 -36
  112. polars/io/cloud/__init__.py +0 -17
  113. polars/io/cloud/_utils.py +0 -80
  114. polars/io/cloud/credential_provider/__init__.py +0 -17
  115. polars/io/cloud/credential_provider/_builder.py +0 -520
  116. polars/io/cloud/credential_provider/_providers.py +0 -618
  117. polars/io/csv/__init__.py +0 -9
  118. polars/io/csv/_utils.py +0 -38
  119. polars/io/csv/batched_reader.py +0 -142
  120. polars/io/csv/functions.py +0 -1495
  121. polars/io/database/__init__.py +0 -6
  122. polars/io/database/_arrow_registry.py +0 -70
  123. polars/io/database/_cursor_proxies.py +0 -147
  124. polars/io/database/_executor.py +0 -578
  125. polars/io/database/_inference.py +0 -314
  126. polars/io/database/_utils.py +0 -144
  127. polars/io/database/functions.py +0 -516
  128. polars/io/delta.py +0 -499
  129. polars/io/iceberg/__init__.py +0 -3
  130. polars/io/iceberg/_utils.py +0 -697
  131. polars/io/iceberg/dataset.py +0 -556
  132. polars/io/iceberg/functions.py +0 -151
  133. polars/io/ipc/__init__.py +0 -8
  134. polars/io/ipc/functions.py +0 -514
  135. polars/io/json/__init__.py +0 -3
  136. polars/io/json/read.py +0 -101
  137. polars/io/ndjson.py +0 -332
  138. polars/io/parquet/__init__.py +0 -17
  139. polars/io/parquet/field_overwrites.py +0 -140
  140. polars/io/parquet/functions.py +0 -722
  141. polars/io/partition.py +0 -491
  142. polars/io/plugins.py +0 -187
  143. polars/io/pyarrow_dataset/__init__.py +0 -5
  144. polars/io/pyarrow_dataset/anonymous_scan.py +0 -109
  145. polars/io/pyarrow_dataset/functions.py +0 -79
  146. polars/io/scan_options/__init__.py +0 -5
  147. polars/io/scan_options/_options.py +0 -59
  148. polars/io/scan_options/cast_options.py +0 -126
  149. polars/io/spreadsheet/__init__.py +0 -6
  150. polars/io/spreadsheet/_utils.py +0 -52
  151. polars/io/spreadsheet/_write_utils.py +0 -647
  152. polars/io/spreadsheet/functions.py +0 -1323
  153. polars/lazyframe/__init__.py +0 -9
  154. polars/lazyframe/engine_config.py +0 -61
  155. polars/lazyframe/frame.py +0 -8564
  156. polars/lazyframe/group_by.py +0 -669
  157. polars/lazyframe/in_process.py +0 -42
  158. polars/lazyframe/opt_flags.py +0 -333
  159. polars/meta/__init__.py +0 -14
  160. polars/meta/build.py +0 -33
  161. polars/meta/index_type.py +0 -27
  162. polars/meta/thread_pool.py +0 -50
  163. polars/meta/versions.py +0 -120
  164. polars/ml/__init__.py +0 -0
  165. polars/ml/torch.py +0 -213
  166. polars/ml/utilities.py +0 -30
  167. polars/plugins.py +0 -155
  168. polars/py.typed +0 -0
  169. polars/pyproject.toml +0 -103
  170. polars/schema.py +0 -265
  171. polars/selectors.py +0 -3117
  172. polars/series/__init__.py +0 -5
  173. polars/series/array.py +0 -776
  174. polars/series/binary.py +0 -254
  175. polars/series/categorical.py +0 -246
  176. polars/series/datetime.py +0 -2275
  177. polars/series/list.py +0 -1087
  178. polars/series/plotting.py +0 -191
  179. polars/series/series.py +0 -9197
  180. polars/series/string.py +0 -2367
  181. polars/series/struct.py +0 -154
  182. polars/series/utils.py +0 -191
  183. polars/sql/__init__.py +0 -7
  184. polars/sql/context.py +0 -677
  185. polars/sql/functions.py +0 -139
  186. polars/string_cache.py +0 -185
  187. polars/testing/__init__.py +0 -13
  188. polars/testing/asserts/__init__.py +0 -9
  189. polars/testing/asserts/frame.py +0 -231
  190. polars/testing/asserts/series.py +0 -219
  191. polars/testing/asserts/utils.py +0 -12
  192. polars/testing/parametric/__init__.py +0 -33
  193. polars/testing/parametric/profiles.py +0 -107
  194. polars/testing/parametric/strategies/__init__.py +0 -22
  195. polars/testing/parametric/strategies/_utils.py +0 -14
  196. polars/testing/parametric/strategies/core.py +0 -615
  197. polars/testing/parametric/strategies/data.py +0 -452
  198. polars/testing/parametric/strategies/dtype.py +0 -436
  199. polars/testing/parametric/strategies/legacy.py +0 -169
  200. polars/type_aliases.py +0 -24
  201. polars_runtime_compat-1.34.0b3.dist-info/RECORD +0 -203
  202. {polars_runtime_compat-1.34.0b3.dist-info → polars_runtime_compat-1.34.0b4.dist-info}/WHEEL +0 -0
  203. {polars_runtime_compat-1.34.0b3.dist-info → polars_runtime_compat-1.34.0b4.dist-info}/licenses/LICENSE +0 -0
polars/series/array.py DELETED
@@ -1,776 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from typing import TYPE_CHECKING, Callable
4
-
5
- from polars import functions as F
6
- from polars._utils.wrap import wrap_s
7
- from polars.series.utils import expr_dispatch
8
-
9
- if TYPE_CHECKING:
10
- from collections.abc import Sequence
11
-
12
- from polars import Series
13
- from polars._plr import PySeries
14
- from polars._typing import IntoExpr, IntoExprColumn
15
- from polars.expr.expr import Expr
16
-
17
-
18
- @expr_dispatch
19
- class ArrayNameSpace:
20
- """Namespace for array related methods."""
21
-
22
- _accessor = "arr"
23
-
24
- def __init__(self, series: Series) -> None:
25
- self._s: PySeries = series._s
26
-
27
- def min(self) -> Series:
28
- """
29
- Compute the min values of the sub-arrays.
30
-
31
- Examples
32
- --------
33
- >>> s = pl.Series("a", [[1, 2], [4, 3]], dtype=pl.Array(pl.Int64, 2))
34
- >>> s.arr.min()
35
- shape: (2,)
36
- Series: 'a' [i64]
37
- [
38
- 1
39
- 3
40
- ]
41
- """
42
-
43
- def max(self) -> Series:
44
- """
45
- Compute the max values of the sub-arrays.
46
-
47
- Examples
48
- --------
49
- >>> s = pl.Series("a", [[1, 2], [4, 3]], dtype=pl.Array(pl.Int64, 2))
50
- >>> s.arr.max()
51
- shape: (2,)
52
- Series: 'a' [i64]
53
- [
54
- 2
55
- 4
56
- ]
57
- """
58
-
59
- def sum(self) -> Series:
60
- """
61
- Compute the sum values of the sub-arrays.
62
-
63
- Notes
64
- -----
65
- If there are no non-null elements in a row, the output is `0`.
66
-
67
- Examples
68
- --------
69
- >>> s = pl.Series([[1, 2], [4, 3]], dtype=pl.Array(pl.Int64, 2))
70
- >>> s.arr.sum()
71
- shape: (2,)
72
- Series: '' [i64]
73
- [
74
- 3
75
- 7
76
- ]
77
- """
78
-
79
- def std(self, ddof: int = 1) -> Series:
80
- """
81
- Compute the std of the values of the sub-arrays.
82
-
83
- Examples
84
- --------
85
- >>> s = pl.Series("a", [[1, 2], [4, 3]], dtype=pl.Array(pl.Int64, 2))
86
- >>> s.arr.std()
87
- shape: (2,)
88
- Series: 'a' [f64]
89
- [
90
- 0.707107
91
- 0.707107
92
- ]
93
- """
94
-
95
- def var(self, ddof: int = 1) -> Series:
96
- """
97
- Compute the var of the values of the sub-arrays.
98
-
99
- Examples
100
- --------
101
- >>> s = pl.Series("a", [[1, 2], [4, 3]], dtype=pl.Array(pl.Int64, 2))
102
- >>> s.arr.var()
103
- shape: (2,)
104
- Series: 'a' [f64]
105
- [
106
- 0.5
107
- 0.5
108
- ]
109
- """
110
-
111
- def median(self) -> Series:
112
- """
113
- Compute the median of the values of the sub-arrays.
114
-
115
- Examples
116
- --------
117
- >>> s = pl.Series("a", [[1, 2], [4, 3]], dtype=pl.Array(pl.Int64, 2))
118
- >>> s.arr.median()
119
- shape: (2,)
120
- Series: 'a' [f64]
121
- [
122
- 1.5
123
- 3.5
124
- ]
125
- """
126
-
127
- def unique(self, *, maintain_order: bool = False) -> Series:
128
- """
129
- Get the unique/distinct values in the array.
130
-
131
- Parameters
132
- ----------
133
- maintain_order
134
- Maintain order of data. This requires more work.
135
-
136
- Returns
137
- -------
138
- Series
139
- Series of data type :class:`List`.
140
-
141
- Examples
142
- --------
143
- >>> s = pl.Series([[1, 1, 2], [3, 4, 5]], dtype=pl.Array(pl.Int64, 3))
144
- >>> s.arr.unique()
145
- shape: (2,)
146
- Series: '' [list[i64]]
147
- [
148
- [1, 2]
149
- [3, 4, 5]
150
- ]
151
- """
152
-
153
- def n_unique(self) -> Series:
154
- """
155
- Count the number of unique values in every sub-arrays.
156
-
157
- Examples
158
- --------
159
- >>> s = pl.Series("a", [[1, 2], [4, 4]], dtype=pl.Array(pl.Int64, 2))
160
- >>> s.arr.n_unique()
161
- shape: (2,)
162
- Series: 'a' [u32]
163
- [
164
- 2
165
- 1
166
- ]
167
- """
168
-
169
- def to_list(self) -> Series:
170
- """
171
- Convert an Array column into a List column with the same inner data type.
172
-
173
- Returns
174
- -------
175
- Series
176
- Series of data type :class:`List`.
177
-
178
- Examples
179
- --------
180
- >>> s = pl.Series([[1, 2], [3, 4]], dtype=pl.Array(pl.Int8, 2))
181
- >>> s.arr.to_list()
182
- shape: (2,)
183
- Series: '' [list[i8]]
184
- [
185
- [1, 2]
186
- [3, 4]
187
- ]
188
- """
189
-
190
- def any(self) -> Series:
191
- """
192
- Evaluate whether any boolean value is true for every subarray.
193
-
194
- Returns
195
- -------
196
- Series
197
- Series of data type :class:`Boolean`.
198
-
199
- Notes
200
- -----
201
- If there are no non-null elements in a row, the output is `False`.
202
-
203
- Examples
204
- --------
205
- >>> s = pl.Series(
206
- ... [[True, True], [False, True], [False, False], [None, None], None],
207
- ... dtype=pl.Array(pl.Boolean, 2),
208
- ... )
209
- >>> s.arr.any()
210
- shape: (5,)
211
- Series: '' [bool]
212
- [
213
- true
214
- true
215
- false
216
- false
217
- null
218
- ]
219
- """
220
-
221
- def len(self) -> Series:
222
- """
223
- Return the number of elements in each array.
224
-
225
- Returns
226
- -------
227
- Series
228
- Series of data type :class:`UInt32`.
229
-
230
- Examples
231
- --------
232
- >>> s = pl.Series("a", [[1, 2], [4, 3]], dtype=pl.Array(pl.Int64, 2))
233
- >>> s.arr.len()
234
- shape: (2,)
235
- Series: 'a' [u32]
236
- [
237
- 2
238
- 2
239
- ]
240
- """
241
-
242
- def slice(
243
- self,
244
- offset: int | Expr,
245
- length: int | Expr | None = None,
246
- *,
247
- as_array: bool = False,
248
- ) -> Series:
249
- """
250
- Slice the sub-arrays.
251
-
252
- Parameters
253
- ----------
254
- offset
255
- The starting index of the slice.
256
- length
257
- The length of the slice.
258
-
259
- Returns
260
- -------
261
- Series
262
- Series of data type :class:`Array`.
263
-
264
- Examples
265
- --------
266
- >>> s = pl.Series(
267
- ... [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12]],
268
- ... dtype=pl.Array(pl.Int64, 6),
269
- ... )
270
- >>> s.arr.slice(1)
271
- shape: (2,)
272
- Series: '' [list[i64]]
273
- [
274
- [2, 3, … 6]
275
- [8, 9, … 12]
276
- ]
277
- >>> s.arr.slice(1, 3, as_array=True)
278
- shape: (2,)
279
- Series: '' [array[i64, 3]]
280
- [
281
- [2, 3, 4]
282
- [8, 9, 10]
283
- ]
284
- >>> s.arr.slice(-2)
285
- shape: (2,)
286
- Series: '' [list[i64]]
287
- [
288
- [5, 6]
289
- [11, 12]
290
- ]
291
- """
292
-
293
- def head(self, n: int | Expr = 5, *, as_array: bool = False) -> Series:
294
- """
295
- Get the first `n` elements of the sub-arrays.
296
-
297
- Parameters
298
- ----------
299
- n
300
- Number of values to return for each sublist.
301
- as_array
302
- Return result as a fixed-length `Array`, otherwise as a `List`.
303
- If true `n` must be a constant value.
304
-
305
- Examples
306
- --------
307
- >>> s = pl.Series(
308
- ... [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12]],
309
- ... dtype=pl.Array(pl.Int64, 6),
310
- ... )
311
- >>> s.arr.head()
312
- shape: (2,)
313
- Series: '' [list[i64]]
314
- [
315
- [1, 2, … 5]
316
- [7, 8, … 11]
317
- ]
318
- >>> s.arr.head(3, as_array=True)
319
- shape: (2,)
320
- Series: '' [array[i64, 3]]
321
- [
322
- [1, 2, 3]
323
- [7, 8, 9]
324
- ]
325
- """
326
-
327
- def tail(self, n: int | Expr = 5, *, as_array: bool = False) -> Series:
328
- """
329
- Slice the last `n` values of every sublist.
330
-
331
- Parameters
332
- ----------
333
- n
334
- Number of values to return for each sublist.
335
- as_array
336
- Return result as a fixed-length `Array`, otherwise as a `List`.
337
- If true `n` must be a constant value.
338
-
339
- Examples
340
- --------
341
- >>> s = pl.Series(
342
- ... [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12]],
343
- ... dtype=pl.Array(pl.Int64, 6),
344
- ... )
345
- >>> s.arr.tail()
346
- shape: (2,)
347
- Series: '' [list[i64]]
348
- [
349
- [2, 3, … 6]
350
- [8, 9, … 12]
351
- ]
352
- >>> s.arr.tail(3, as_array=True)
353
- shape: (2,)
354
- Series: '' [array[i64, 3]]
355
- [
356
- [4, 5, 6]
357
- [10, 11, 12]
358
- ]
359
- """
360
-
361
- def all(self) -> Series:
362
- """
363
- Evaluate whether all boolean values are true for every subarray.
364
-
365
- Returns
366
- -------
367
- Series
368
- Series of data type :class:`Boolean`.
369
-
370
- Notes
371
- -----
372
- If there are no non-null elements in a row, the output is `True`.
373
-
374
- Examples
375
- --------
376
- >>> s = pl.Series(
377
- ... [[True, True], [False, True], [False, False], [None, None], None],
378
- ... dtype=pl.Array(pl.Boolean, 2),
379
- ... )
380
- >>> s.arr.all()
381
- shape: (5,)
382
- Series: '' [bool]
383
- [
384
- true
385
- false
386
- false
387
- true
388
- null
389
- ]
390
- """
391
-
392
- def sort(
393
- self,
394
- *,
395
- descending: bool = False,
396
- nulls_last: bool = False,
397
- multithreaded: bool = True,
398
- ) -> Series:
399
- """
400
- Sort the arrays in this column.
401
-
402
- Parameters
403
- ----------
404
- descending
405
- Sort in descending order.
406
- nulls_last
407
- Place null values last.
408
- multithreaded
409
- Sort using multiple threads.
410
-
411
- Examples
412
- --------
413
- >>> s = pl.Series("a", [[3, 2, 1], [9, 1, 2]], dtype=pl.Array(pl.Int64, 3))
414
- >>> s.arr.sort()
415
- shape: (2,)
416
- Series: 'a' [array[i64, 3]]
417
- [
418
- [1, 2, 3]
419
- [1, 2, 9]
420
- ]
421
- >>> s.arr.sort(descending=True)
422
- shape: (2,)
423
- Series: 'a' [array[i64, 3]]
424
- [
425
- [3, 2, 1]
426
- [9, 2, 1]
427
- ]
428
-
429
- """
430
-
431
- def reverse(self) -> Series:
432
- """
433
- Reverse the arrays in this column.
434
-
435
- Examples
436
- --------
437
- >>> s = pl.Series("a", [[3, 2, 1], [9, 1, 2]], dtype=pl.Array(pl.Int64, 3))
438
- >>> s.arr.reverse()
439
- shape: (2,)
440
- Series: 'a' [array[i64, 3]]
441
- [
442
- [1, 2, 3]
443
- [2, 1, 9]
444
- ]
445
-
446
- """
447
-
448
- def arg_min(self) -> Series:
449
- """
450
- Retrieve the index of the minimal value in every sub-array.
451
-
452
- Returns
453
- -------
454
- Series
455
- Series of data type :class:`UInt32` or :class:`UInt64`
456
- (depending on compilation).
457
-
458
- Examples
459
- --------
460
- >>> s = pl.Series("a", [[3, 2, 1], [9, 1, 2]], dtype=pl.Array(pl.Int64, 3))
461
- >>> s.arr.arg_min()
462
- shape: (2,)
463
- Series: 'a' [u32]
464
- [
465
- 2
466
- 1
467
- ]
468
-
469
- """
470
-
471
- def arg_max(self) -> Series:
472
- """
473
- Retrieve the index of the maximum value in every sub-array.
474
-
475
- Returns
476
- -------
477
- Series
478
- Series of data type :class:`UInt32` or :class:`UInt64`
479
- (depending on compilation).
480
-
481
- Examples
482
- --------
483
- >>> s = pl.Series("a", [[0, 9, 3], [9, 1, 2]], dtype=pl.Array(pl.Int64, 3))
484
- >>> s.arr.arg_max()
485
- shape: (2,)
486
- Series: 'a' [u32]
487
- [
488
- 1
489
- 0
490
- ]
491
-
492
- """
493
-
494
- def get(self, index: int | IntoExprColumn, *, null_on_oob: bool = False) -> Series:
495
- """
496
- Get the value by index in the sub-arrays.
497
-
498
- So index `0` would return the first item of every sublist
499
- and index `-1` would return the last item of every sublist
500
- if an index is out of bounds, it will return a `None`.
501
-
502
- Parameters
503
- ----------
504
- index
505
- Index to return per sublist
506
- null_on_oob
507
- Behavior if an index is out of bounds:
508
- True -> set as null
509
- False -> raise an error
510
-
511
- Returns
512
- -------
513
- Series
514
- Series of innter data type.
515
-
516
- Examples
517
- --------
518
- >>> s = pl.Series(
519
- ... "a", [[1, 2, 3], [4, 5, 6], [7, 8, 9]], dtype=pl.Array(pl.Int32, 3)
520
- ... )
521
- >>> s.arr.get(pl.Series([1, -2, 0]), null_on_oob=True)
522
- shape: (3,)
523
- Series: 'a' [i32]
524
- [
525
- 2
526
- 5
527
- 7
528
- ]
529
-
530
- """
531
-
532
- def first(self) -> Series:
533
- """
534
- Get the first value of the sub-arrays.
535
-
536
- Examples
537
- --------
538
- >>> s = pl.Series(
539
- ... "a", [[1, 2, 3], [4, 5, 6], [7, 8, 9]], dtype=pl.Array(pl.Int32, 3)
540
- ... )
541
- >>> s.arr.first()
542
- shape: (3,)
543
- Series: 'a' [i32]
544
- [
545
- 1
546
- 4
547
- 7
548
- ]
549
-
550
- """
551
-
552
- def last(self) -> Series:
553
- """
554
- Get the last value of the sub-arrays.
555
-
556
- Examples
557
- --------
558
- >>> s = pl.Series(
559
- ... "a", [[1, 2, 3], [4, 5, 6], [7, 9, 8]], dtype=pl.Array(pl.Int32, 3)
560
- ... )
561
- >>> s.arr.last()
562
- shape: (3,)
563
- Series: 'a' [i32]
564
- [
565
- 3
566
- 6
567
- 8
568
- ]
569
-
570
- """
571
-
572
- def join(self, separator: IntoExprColumn, *, ignore_nulls: bool = True) -> Series:
573
- """
574
- Join all string items in a sub-array and place a separator between them.
575
-
576
- This errors if inner type of array `!= String`.
577
-
578
- Parameters
579
- ----------
580
- separator
581
- string to separate the items with
582
- ignore_nulls
583
- Ignore null values (default).
584
-
585
- If set to ``False``, null values will be propagated.
586
- If the sub-list contains any null values, the output is ``None``.
587
-
588
- Returns
589
- -------
590
- Series
591
- Series of data type :class:`String`.
592
-
593
- Examples
594
- --------
595
- >>> s = pl.Series([["x", "y"], ["a", "b"]], dtype=pl.Array(pl.String, 2))
596
- >>> s.arr.join(separator="-")
597
- shape: (2,)
598
- Series: '' [str]
599
- [
600
- "x-y"
601
- "a-b"
602
- ]
603
-
604
- """
605
-
606
- def explode(self) -> Series:
607
- """
608
- Returns a column with a separate row for every array element.
609
-
610
- Returns
611
- -------
612
- Series
613
- Series with the data type of the array elements.
614
-
615
- Examples
616
- --------
617
- >>> s = pl.Series("a", [[1, 2, 3], [4, 5, 6]], dtype=pl.Array(pl.Int64, 3))
618
- >>> s.arr.explode()
619
- shape: (6,)
620
- Series: 'a' [i64]
621
- [
622
- 1
623
- 2
624
- 3
625
- 4
626
- 5
627
- 6
628
- ]
629
- """
630
-
631
- def contains(self, item: IntoExpr, *, nulls_equal: bool = True) -> Series:
632
- """
633
- Check if sub-arrays contain the given item.
634
-
635
- Parameters
636
- ----------
637
- item
638
- Item that will be checked for membership
639
- nulls_equal : bool, default True
640
- If True, treat null as a distinct value. Null values will not propagate.
641
-
642
- Returns
643
- -------
644
- Series
645
- Series of data type :class:`Boolean`.
646
-
647
- Examples
648
- --------
649
- >>> s = pl.Series(
650
- ... "a", [[3, 2, 1], [1, 2, 3], [4, 5, 6]], dtype=pl.Array(pl.Int32, 3)
651
- ... )
652
- >>> s.arr.contains(1)
653
- shape: (3,)
654
- Series: 'a' [bool]
655
- [
656
- true
657
- true
658
- false
659
- ]
660
-
661
- """
662
-
663
- def count_matches(self, element: IntoExpr) -> Series:
664
- """
665
- Count how often the value produced by `element` occurs.
666
-
667
- Parameters
668
- ----------
669
- element
670
- An expression that produces a single value
671
-
672
- Examples
673
- --------
674
- >>> s = pl.Series("a", [[1, 2, 3], [2, 2, 2]], dtype=pl.Array(pl.Int64, 3))
675
- >>> s.arr.count_matches(2)
676
- shape: (2,)
677
- Series: 'a' [u32]
678
- [
679
- 1
680
- 3
681
- ]
682
-
683
- """
684
-
685
- def to_struct(
686
- self,
687
- fields: Callable[[int], str] | Sequence[str] | None = None,
688
- ) -> Series:
689
- """
690
- Convert the series of type `Array` to a series of type `Struct`.
691
-
692
- Parameters
693
- ----------
694
- fields
695
- If the name and number of the desired fields is known in advance
696
- a list of field names can be given, which will be assigned by index.
697
- Otherwise, to dynamically assign field names, a custom function can be
698
- used; if neither are set, fields will be `field_0, field_1 .. field_n`.
699
-
700
- Examples
701
- --------
702
- Convert array to struct with default field name assignment:
703
-
704
- >>> s1 = pl.Series("n", [[0, 1, 2], [3, 4, 5]], dtype=pl.Array(pl.Int8, 3))
705
- >>> s2 = s1.arr.to_struct()
706
- >>> s2
707
- shape: (2,)
708
- Series: 'n' [struct[3]]
709
- [
710
- {0,1,2}
711
- {3,4,5}
712
- ]
713
- >>> s2.struct.fields
714
- ['field_0', 'field_1', 'field_2']
715
-
716
- Convert array to struct with field name assignment by function/index:
717
-
718
- >>> s3 = s1.arr.to_struct(fields=lambda idx: f"n{idx:02}")
719
- >>> s3.struct.fields
720
- ['n00', 'n01', 'n02']
721
-
722
- Convert array to struct with field name assignment by
723
- index from a list of names:
724
-
725
- >>> s1.arr.to_struct(fields=["one", "two", "three"]).struct.unnest()
726
- shape: (2, 3)
727
- ┌─────┬─────┬───────┐
728
- │ one ┆ two ┆ three │
729
- │ --- ┆ --- ┆ --- │
730
- │ i8 ┆ i8 ┆ i8 │
731
- ╞═════╪═════╪═══════╡
732
- │ 0 ┆ 1 ┆ 2 │
733
- │ 3 ┆ 4 ┆ 5 │
734
- └─────┴─────┴───────┘
735
- """
736
- s = wrap_s(self._s)
737
- return s.to_frame().select(F.col(s.name).arr.to_struct(fields)).to_series()
738
-
739
- def shift(self, n: int | IntoExprColumn = 1) -> Series:
740
- """
741
- Shift array values by the given number of indices.
742
-
743
- Parameters
744
- ----------
745
- n
746
- Number of indices to shift forward. If a negative value is passed, values
747
- are shifted in the opposite direction instead.
748
-
749
- Notes
750
- -----
751
- This method is similar to the `LAG` operation in SQL when the value for `n`
752
- is positive. With a negative value for `n`, it is similar to `LEAD`.
753
-
754
- Examples
755
- --------
756
- By default, array values are shifted forward by one index.
757
-
758
- >>> s = pl.Series([[1, 2, 3], [4, 5, 6]], dtype=pl.Array(pl.Int64, 3))
759
- >>> s.arr.shift()
760
- shape: (2,)
761
- Series: '' [array[i64, 3]]
762
- [
763
- [null, 1, 2]
764
- [null, 4, 5]
765
- ]
766
-
767
- Pass a negative value to shift in the opposite direction instead.
768
-
769
- >>> s.arr.shift(-2)
770
- shape: (2,)
771
- Series: '' [array[i64, 3]]
772
- [
773
- [3, null, null]
774
- [6, null, null]
775
- ]
776
- """