polars-df 0.10.0-aarch64-linux → 0.12.0-aarch64-linux

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 (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +27 -0
  3. data/Cargo.lock +392 -351
  4. data/LICENSE-THIRD-PARTY.txt +1125 -865
  5. data/README.md +6 -6
  6. data/lib/polars/3.1/polars.so +0 -0
  7. data/lib/polars/3.2/polars.so +0 -0
  8. data/lib/polars/3.3/polars.so +0 -0
  9. data/lib/polars/array_expr.rb +4 -4
  10. data/lib/polars/batched_csv_reader.rb +11 -5
  11. data/lib/polars/cat_expr.rb +0 -36
  12. data/lib/polars/cat_name_space.rb +0 -37
  13. data/lib/polars/convert.rb +6 -1
  14. data/lib/polars/data_frame.rb +176 -403
  15. data/lib/polars/data_types.rb +1 -1
  16. data/lib/polars/date_time_expr.rb +525 -572
  17. data/lib/polars/date_time_name_space.rb +263 -460
  18. data/lib/polars/dynamic_group_by.rb +5 -5
  19. data/lib/polars/exceptions.rb +7 -0
  20. data/lib/polars/expr.rb +1394 -243
  21. data/lib/polars/expr_dispatch.rb +1 -1
  22. data/lib/polars/functions/aggregation/horizontal.rb +8 -8
  23. data/lib/polars/functions/as_datatype.rb +63 -40
  24. data/lib/polars/functions/lazy.rb +63 -14
  25. data/lib/polars/functions/lit.rb +1 -1
  26. data/lib/polars/functions/range/date_range.rb +90 -57
  27. data/lib/polars/functions/range/datetime_range.rb +149 -0
  28. data/lib/polars/functions/range/int_range.rb +2 -2
  29. data/lib/polars/functions/range/time_range.rb +141 -0
  30. data/lib/polars/functions/repeat.rb +1 -1
  31. data/lib/polars/functions/whenthen.rb +1 -1
  32. data/lib/polars/group_by.rb +88 -23
  33. data/lib/polars/io/avro.rb +24 -0
  34. data/lib/polars/{io.rb → io/csv.rb} +299 -493
  35. data/lib/polars/io/database.rb +73 -0
  36. data/lib/polars/io/ipc.rb +247 -0
  37. data/lib/polars/io/json.rb +29 -0
  38. data/lib/polars/io/ndjson.rb +80 -0
  39. data/lib/polars/io/parquet.rb +227 -0
  40. data/lib/polars/lazy_frame.rb +143 -272
  41. data/lib/polars/lazy_group_by.rb +100 -3
  42. data/lib/polars/list_expr.rb +11 -11
  43. data/lib/polars/list_name_space.rb +5 -1
  44. data/lib/polars/rolling_group_by.rb +7 -9
  45. data/lib/polars/series.rb +103 -187
  46. data/lib/polars/string_expr.rb +78 -102
  47. data/lib/polars/string_name_space.rb +5 -4
  48. data/lib/polars/testing.rb +2 -2
  49. data/lib/polars/utils/constants.rb +9 -0
  50. data/lib/polars/utils/convert.rb +97 -0
  51. data/lib/polars/utils/parse.rb +89 -0
  52. data/lib/polars/utils/various.rb +76 -0
  53. data/lib/polars/utils/wrap.rb +19 -0
  54. data/lib/polars/utils.rb +8 -300
  55. data/lib/polars/version.rb +1 -1
  56. data/lib/polars/whenthen.rb +6 -6
  57. data/lib/polars.rb +20 -1
  58. metadata +17 -4
@@ -23,9 +23,9 @@ module Polars
23
23
  # @return [Object]
24
24
  #
25
25
  # @example
26
- # s = Polars.date_range(DateTime.new(2001, 1, 1), DateTime.new(2001, 1, 3), "1d")
26
+ # s = Polars::Series.new([Date.new(2001, 1, 1), Date.new(2001, 1, 2), Date.new(2001, 1, 3)])
27
27
  # s.dt.min
28
- # # => 2001-01-01 00:00:00 UTC
28
+ # # => Mon, 01 Jan 2001
29
29
  def min
30
30
  Utils.wrap_s(_s).min
31
31
  end
@@ -35,9 +35,9 @@ module Polars
35
35
  # @return [Object]
36
36
  #
37
37
  # @example
38
- # s = Polars.date_range(DateTime.new(2001, 1, 1), DateTime.new(2001, 1, 3), "1d")
38
+ # s = Polars::Series.new([Date.new(2001, 1, 1), Date.new(2001, 1, 2), Date.new(2001, 1, 3)])
39
39
  # s.dt.max
40
- # # => 2001-01-03 00:00:00 UTC
40
+ # # => Wed, 03 Jan 2001
41
41
  def max
42
42
  Utils.wrap_s(_s).max
43
43
  end
@@ -47,10 +47,12 @@ module Polars
47
47
  # @return [Object]
48
48
  #
49
49
  # @example
50
- # date = Polars.date_range(DateTime.new(2001, 1, 1), DateTime.new(2001, 1, 3), "1d")
50
+ # date = Polars.datetime_range(
51
+ # DateTime.new(2001, 1, 1), DateTime.new(2001, 1, 3), "1d", eager: true
52
+ # ).alias("datetime")
51
53
  # # =>
52
54
  # # shape: (3,)
53
- # # Series: '' [datetime[μs]]
55
+ # # Series: 'datetime' [datetime[ns]]
54
56
  # # [
55
57
  # # 2001-01-01 00:00:00
56
58
  # # 2001-01-02 00:00:00
@@ -61,16 +63,7 @@ module Polars
61
63
  # date.dt.median
62
64
  # # => 2001-01-02 00:00:00 UTC
63
65
  def median
64
- s = Utils.wrap_s(_s)
65
- out = s.median
66
- if !out.nil?
67
- if s.dtype == Date
68
- return Utils._to_ruby_date(out.to_i)
69
- else
70
- return Utils._to_ruby_datetime(out.to_i, s.time_unit)
71
- end
72
- end
73
- nil
66
+ _s.median
74
67
  end
75
68
 
76
69
  # Return mean as Ruby object.
@@ -78,62 +71,69 @@ module Polars
78
71
  # @return [Object]
79
72
  #
80
73
  # @example
81
- # date = Polars.date_range(DateTime.new(2001, 1, 1), DateTime.new(2001, 1, 3), "1d")
82
- # # =>
83
- # # shape: (3,)
84
- # # Series: '' [datetime[μs]]
85
- # # [
86
- # # 2001-01-01 00:00:00
87
- # # 2001-01-02 00:00:00
88
- # # 2001-01-03 00:00:00
89
- # # ]
74
+ # s = Polars::Series.new([Date.new(2001, 1, 1), Date.new(2001, 1, 2)])
75
+ # s.dt.mean
76
+ # # => 2001-01-01 12:00:00 UTC
90
77
  #
91
78
  # @example
92
- # date.dt.mean
79
+ # s = Polars::Series.new(
80
+ # [DateTime.new(2001, 1, 1), DateTime.new(2001, 1, 2), DateTime.new(2001, 1, 3)]
81
+ # )
82
+ # s.dt.mean
93
83
  # # => 2001-01-02 00:00:00 UTC
94
84
  def mean
95
- s = Utils.wrap_s(_s)
96
- out = s.mean.to_i
97
- if !out.nil?
98
- if s.dtype == Date
99
- return Utils._to_ruby_date(out.to_i)
100
- else
101
- return Utils._to_ruby_datetime(out.to_i, s.time_unit)
102
- end
103
- end
104
- nil
85
+ _s.mean
105
86
  end
106
87
 
107
- # Format Date/datetime with a formatting rule.
88
+ # Convert a Date/Time/Datetime column into a String column with the given format.
108
89
  #
109
- # See [chrono strftime/strptime](https://docs.rs/chrono/0.4.19/chrono/format/strftime/index.html).
90
+ # Similar to `cast(Polars::String)`, but this method allows you to customize the
91
+ # formatting of the resulting string.
92
+ #
93
+ # @param format [String]
94
+ # Format to use, refer to the `chrono strftime documentation
95
+ # <https://docs.rs/chrono/latest/chrono/format/strftime/index.html>`_
96
+ # for specification. Example: `"%y-%m-%d"`.
110
97
  #
111
98
  # @return [Series]
112
99
  #
113
100
  # @example
114
- # start = DateTime.new(2001, 1, 1)
115
- # stop = DateTime.new(2001, 1, 4)
116
- # date = Polars.date_range(start, stop, "1d")
101
+ # s = Polars::Series.new(
102
+ # "datetime",
103
+ # [DateTime.new(2020, 3, 1), DateTime.new(2020, 4, 1), DateTime.new(2020, 5, 1)],
104
+ # )
105
+ # s.dt.to_string("%Y/%m/%d")
117
106
  # # =>
118
- # # shape: (4,)
119
- # # Series: '' [datetime[μs]]
107
+ # # shape: (3,)
108
+ # # Series: 'datetime' [str]
120
109
  # # [
121
- # # 2001-01-01 00:00:00
122
- # # 2001-01-02 00:00:00
123
- # # 2001-01-03 00:00:00
124
- # # 2001-01-04 00:00:00
110
+ # # "2020/03/01"
111
+ # # "2020/04/01"
112
+ # # "2020/05/01"
125
113
  # # ]
114
+ def to_string(format)
115
+ super
116
+ end
117
+
118
+ # Format Date/datetime with a formatting rule.
119
+ #
120
+ # See [chrono strftime/strptime](https://docs.rs/chrono/0.4.19/chrono/format/strftime/index.html).
121
+ #
122
+ # @return [Series]
126
123
  #
127
124
  # @example
128
- # date.dt.strftime("%Y-%m-%d")
125
+ # s = Polars::Series.new(
126
+ # "datetime",
127
+ # [DateTime.new(2020, 3, 1), DateTime.new(2020, 4, 1), DateTime.new(2020, 5, 1)]
128
+ # )
129
+ # s.dt.strftime("%Y/%m/%d")
129
130
  # # =>
130
- # # shape: (4,)
131
- # # Series: '' [str]
131
+ # # shape: (3,)
132
+ # # Series: 'datetime' [str]
132
133
  # # [
133
- # # "2001-01-01"
134
- # # "2001-01-02"
135
- # # "2001-01-03"
136
- # # "2001-01-04"
134
+ # # "2020/03/01"
135
+ # # "2020/04/01"
136
+ # # "2020/05/01"
137
137
  # # ]
138
138
  def strftime(fmt)
139
139
  super
@@ -148,22 +148,11 @@ module Polars
148
148
  # @return [Series]
149
149
  #
150
150
  # @example
151
- # start = DateTime.new(2001, 1, 1)
152
- # stop = DateTime.new(2002, 1, 1)
153
- # date = Polars.date_range(start, stop, "1y")
154
- # # =>
155
- # # shape: (2,)
156
- # # Series: '' [datetime[μs]]
157
- # # [
158
- # # 2001-01-01 00:00:00
159
- # # 2002-01-01 00:00:00
160
- # # ]
161
- #
162
- # @example
163
- # date.dt.year
151
+ # s = Polars::Series.new("date", [Date.new(2001, 1, 1), Date.new(2002, 1, 1)])
152
+ # s.dt.year
164
153
  # # =>
165
154
  # # shape: (2,)
166
- # # Series: '' [i32]
155
+ # # Series: 'date' [i32]
167
156
  # # [
168
157
  # # 2001
169
158
  # # 2002
@@ -203,24 +192,13 @@ module Polars
203
192
  # @return [Series]
204
193
  #
205
194
  # @example
206
- # start = DateTime.new(2001, 1, 1)
207
- # stop = DateTime.new(2001, 4, 1)
208
- # date = Polars.date_range(start, stop, "1mo")
209
- # # =>
210
- # # shape: (4,)
211
- # # Series: '' [datetime[μs]]
212
- # # [
213
- # # 2001-01-01 00:00:00
214
- # # 2001-02-01 00:00:00
215
- # # 2001-03-01 00:00:00
216
- # # 2001-04-01 00:00:00
217
- # # ]
218
- #
219
- # @example
195
+ # date = Polars.date_range(
196
+ # Date.new(2001, 1, 1), Date.new(2001, 4, 1), "1mo", eager: true
197
+ # ).alias("date")
220
198
  # date.dt.quarter
221
199
  # # =>
222
200
  # # shape: (4,)
223
- # # Series: '' [i8]
201
+ # # Series: 'date' [i8]
224
202
  # # [
225
203
  # # 1
226
204
  # # 1
@@ -241,24 +219,13 @@ module Polars
241
219
  # @return [Series]
242
220
  #
243
221
  # @example
244
- # start = DateTime.new(2001, 1, 1)
245
- # stop = DateTime.new(2001, 4, 1)
246
- # date = Polars.date_range(start, stop, "1mo")
247
- # # =>
248
- # # shape: (4,)
249
- # # Series: '' [datetime[μs]]
250
- # # [
251
- # # 2001-01-01 00:00:00
252
- # # 2001-02-01 00:00:00
253
- # # 2001-03-01 00:00:00
254
- # # 2001-04-01 00:00:00
255
- # # ]
256
- #
257
- # @example
222
+ # date = Polars.date_range(
223
+ # Date.new(2001, 1, 1), Date.new(2001, 4, 1), "1mo", eager: true
224
+ # ).alias("date")
258
225
  # date.dt.month
259
226
  # # =>
260
227
  # # shape: (4,)
261
- # # Series: '' [i8]
228
+ # # Series: 'date' [i8]
262
229
  # # [
263
230
  # # 1
264
231
  # # 2
@@ -279,24 +246,13 @@ module Polars
279
246
  # @return [Series]
280
247
  #
281
248
  # @example
282
- # start = DateTime.new(2001, 1, 1)
283
- # stop = DateTime.new(2001, 4, 1)
284
- # date = Polars.date_range(start, stop, "1mo")
285
- # # =>
286
- # # shape: (4,)
287
- # # Series: '' [datetime[μs]]
288
- # # [
289
- # # 2001-01-01 00:00:00
290
- # # 2001-02-01 00:00:00
291
- # # 2001-03-01 00:00:00
292
- # # 2001-04-01 00:00:00
293
- # # ]
294
- #
295
- # @example
249
+ # date = Polars.date_range(
250
+ # Date.new(2001, 1, 1), Date.new(2001, 4, 1), "1mo", eager: true
251
+ # ).alias("date")
296
252
  # date.dt.week
297
253
  # # =>
298
254
  # # shape: (4,)
299
- # # Series: '' [i8]
255
+ # # Series: 'date' [i8]
300
256
  # # [
301
257
  # # 1
302
258
  # # 5
@@ -316,27 +272,13 @@ module Polars
316
272
  # @return [Series]
317
273
  #
318
274
  # @example
319
- # start = DateTime.new(2001, 1, 1)
320
- # stop = DateTime.new(2001, 1, 7)
321
- # date = Polars.date_range(start, stop, "1d")
322
- # # =>
323
- # # shape: (7,)
324
- # # Series: '' [datetime[μs]]
325
- # # [
326
- # # 2001-01-01 00:00:00
327
- # # 2001-01-02 00:00:00
328
- # # 2001-01-03 00:00:00
329
- # # 2001-01-04 00:00:00
330
- # # 2001-01-05 00:00:00
331
- # # 2001-01-06 00:00:00
332
- # # 2001-01-07 00:00:00
333
- # # ]
334
- #
335
- # @example
336
- # date.dt.weekday
275
+ # s = Polars.date_range(Date.new(2001, 1, 1), Date.new(2001, 1, 7), eager: true).alias(
276
+ # "date"
277
+ # )
278
+ # s.dt.weekday
337
279
  # # =>
338
280
  # # shape: (7,)
339
- # # Series: '' [i8]
281
+ # # Series: 'date' [i8]
340
282
  # # [
341
283
  # # 1
342
284
  # # 2
@@ -360,25 +302,13 @@ module Polars
360
302
  # @return [Series]
361
303
  #
362
304
  # @example
363
- # start = DateTime.new(2001, 1, 1)
364
- # stop = DateTime.new(2001, 1, 9)
365
- # date = Polars.date_range(start, stop, "2d")
366
- # # =>
367
- # # shape: (5,)
368
- # # Series: '' [datetime[μs]]
369
- # # [
370
- # # 2001-01-01 00:00:00
371
- # # 2001-01-03 00:00:00
372
- # # 2001-01-05 00:00:00
373
- # # 2001-01-07 00:00:00
374
- # # 2001-01-09 00:00:00
375
- # # ]
376
- #
377
- # @example
378
- # date.dt.day
305
+ # s = Polars.date_range(
306
+ # Date.new(2001, 1, 1), Date.new(2001, 1, 9), "2d", eager: true
307
+ # ).alias("date")
308
+ # s.dt.day
379
309
  # # =>
380
310
  # # shape: (5,)
381
- # # Series: '' [i8]
311
+ # # Series: 'date' [i8]
382
312
  # # [
383
313
  # # 1
384
314
  # # 3
@@ -400,23 +330,13 @@ module Polars
400
330
  # @return [Series]
401
331
  #
402
332
  # @example
403
- # start = DateTime.new(2001, 1, 1)
404
- # stop = DateTime.new(2001, 3, 1)
405
- # date = Polars.date_range(start, stop, "1mo")
406
- # # =>
407
- # # shape: (3,)
408
- # # Series: '' [datetime[μs]]
409
- # # [
410
- # # 2001-01-01 00:00:00
411
- # # 2001-02-01 00:00:00
412
- # # 2001-03-01 00:00:00
413
- # # ]
414
- #
415
- # @example
416
- # date.dt.ordinal_day
333
+ # s = Polars.date_range(
334
+ # Date.new(2001, 1, 1), Date.new(2001, 3, 1), "1mo", eager: true
335
+ # ).alias("date")
336
+ # s.dt.ordinal_day
417
337
  # # =>
418
338
  # # shape: (3,)
419
- # # Series: '' [i16]
339
+ # # Series: 'date' [i16]
420
340
  # # [
421
341
  # # 1
422
342
  # # 32
@@ -437,22 +357,11 @@ module Polars
437
357
  # @example
438
358
  # start = DateTime.new(2001, 1, 1)
439
359
  # stop = DateTime.new(2001, 1, 1, 3)
440
- # date = Polars.date_range(start, stop, "1h")
441
- # # =>
442
- # # shape: (4,)
443
- # # Series: '' [datetime[μs]]
444
- # # [
445
- # # 2001-01-01 00:00:00
446
- # # 2001-01-01 01:00:00
447
- # # 2001-01-01 02:00:00
448
- # # 2001-01-01 03:00:00
449
- # # ]
450
- #
451
- # @example
360
+ # date = Polars.datetime_range(start, stop, "1h", eager: true).alias("datetime")
452
361
  # date.dt.hour
453
362
  # # =>
454
363
  # # shape: (4,)
455
- # # Series: '' [i8]
364
+ # # Series: 'datetime' [i8]
456
365
  # # [
457
366
  # # 0
458
367
  # # 1
@@ -474,21 +383,11 @@ module Polars
474
383
  # @example
475
384
  # start = DateTime.new(2001, 1, 1)
476
385
  # stop = DateTime.new(2001, 1, 1, 0, 4, 0)
477
- # date = Polars.date_range(start, stop, "2m")
478
- # # =>
479
- # # shape: (3,)
480
- # # Series: '' [datetime[μs]]
481
- # # [
482
- # # 2001-01-01 00:00:00
483
- # # 2001-01-01 00:02:00
484
- # # 2001-01-01 00:04:00
485
- # # ]
486
- #
487
- # @example
386
+ # date = Polars.datetime_range(start, stop, "2m", eager: true).alias("datetime")
488
387
  # date.dt.minute
489
388
  # # =>
490
389
  # # shape: (3,)
491
- # # Series: '' [i8]
390
+ # # Series: 'datetime' [i8]
492
391
  # # [
493
392
  # # 0
494
393
  # # 2
@@ -511,27 +410,11 @@ module Polars
511
410
  # @example
512
411
  # start = DateTime.new(2001, 1, 1)
513
412
  # stop = DateTime.new(2001, 1, 1, 0, 0, 4)
514
- # date = Polars.date_range(start, stop, "500ms")
515
- # # =>
516
- # # shape: (9,)
517
- # # Series: '' [datetime[μs]]
518
- # # [
519
- # # 2001-01-01 00:00:00
520
- # # 2001-01-01 00:00:00.500
521
- # # 2001-01-01 00:00:01
522
- # # 2001-01-01 00:00:01.500
523
- # # 2001-01-01 00:00:02
524
- # # 2001-01-01 00:00:02.500
525
- # # 2001-01-01 00:00:03
526
- # # 2001-01-01 00:00:03.500
527
- # # 2001-01-01 00:00:04
528
- # # ]
529
- #
530
- # @example
413
+ # date = Polars.datetime_range(start, stop, "500ms", eager: true).alias("datetime")
531
414
  # date.dt.second
532
415
  # # =>
533
416
  # # shape: (9,)
534
- # # Series: '' [i8]
417
+ # # Series: 'datetime' [i8]
535
418
  # # [
536
419
  # # 0
537
420
  # # 0
@@ -548,7 +431,7 @@ module Polars
548
431
  # date.dt.second(fractional: true)
549
432
  # # =>
550
433
  # # shape: (9,)
551
- # # Series: '' [f64]
434
+ # # Series: 'datetime' [f64]
552
435
  # # [
553
436
  # # 0.0
554
437
  # # 0.5
@@ -573,27 +456,11 @@ module Polars
573
456
  # @example
574
457
  # start = DateTime.new(2001, 1, 1)
575
458
  # stop = DateTime.new(2001, 1, 1, 0, 0, 4)
576
- # date = Polars.date_range(start, stop, "500ms")
577
- # # =>
578
- # # shape: (9,)
579
- # # Series: '' [datetime[μs]]
580
- # # [
581
- # # 2001-01-01 00:00:00
582
- # # 2001-01-01 00:00:00.500
583
- # # 2001-01-01 00:00:01
584
- # # 2001-01-01 00:00:01.500
585
- # # 2001-01-01 00:00:02
586
- # # 2001-01-01 00:00:02.500
587
- # # 2001-01-01 00:00:03
588
- # # 2001-01-01 00:00:03.500
589
- # # 2001-01-01 00:00:04
590
- # # ]
591
- #
592
- # @example
459
+ # date = Polars.datetime_range(start, stop, "500ms", eager: true).alias("datetime")
593
460
  # date.dt.millisecond
594
461
  # # =>
595
462
  # # shape: (9,)
596
- # # Series: '' [i32]
463
+ # # Series: 'datetime' [i32]
597
464
  # # [
598
465
  # # 0
599
466
  # # 500
@@ -618,27 +485,11 @@ module Polars
618
485
  # @example
619
486
  # start = DateTime.new(2001, 1, 1)
620
487
  # stop = DateTime.new(2001, 1, 1, 0, 0, 4)
621
- # date = Polars.date_range(start, stop, "500ms")
622
- # # =>
623
- # # shape: (9,)
624
- # # Series: '' [datetime[μs]]
625
- # # [
626
- # # 2001-01-01 00:00:00
627
- # # 2001-01-01 00:00:00.500
628
- # # 2001-01-01 00:00:01
629
- # # 2001-01-01 00:00:01.500
630
- # # 2001-01-01 00:00:02
631
- # # 2001-01-01 00:00:02.500
632
- # # 2001-01-01 00:00:03
633
- # # 2001-01-01 00:00:03.500
634
- # # 2001-01-01 00:00:04
635
- # # ]
636
- #
637
- # @example
488
+ # date = Polars.datetime_range(start, stop, "500ms", eager: true).alias("datetime")
638
489
  # date.dt.microsecond
639
490
  # # =>
640
491
  # # shape: (9,)
641
- # # Series: '' [i32]
492
+ # # Series: 'datetime' [i32]
642
493
  # # [
643
494
  # # 0
644
495
  # # 500000
@@ -663,27 +514,11 @@ module Polars
663
514
  # @example
664
515
  # start = DateTime.new(2001, 1, 1)
665
516
  # stop = DateTime.new(2001, 1, 1, 0, 0, 4)
666
- # date = Polars.date_range(start, stop, "500ms")
667
- # # =>
668
- # # shape: (9,)
669
- # # Series: '' [datetime[μs]]
670
- # # [
671
- # # 2001-01-01 00:00:00
672
- # # 2001-01-01 00:00:00.500
673
- # # 2001-01-01 00:00:01
674
- # # 2001-01-01 00:00:01.500
675
- # # 2001-01-01 00:00:02
676
- # # 2001-01-01 00:00:02.500
677
- # # 2001-01-01 00:00:03
678
- # # 2001-01-01 00:00:03.500
679
- # # 2001-01-01 00:00:04
680
- # # ]
681
- #
682
- # @example
517
+ # date = Polars.datetime_range(start, stop, "500ms", eager: true).alias("datetime")
683
518
  # date.dt.nanosecond
684
519
  # # =>
685
520
  # # shape: (9,)
686
- # # Series: '' [i32]
521
+ # # Series: 'datetime' [i32]
687
522
  # # [
688
523
  # # 0
689
524
  # # 500000000
@@ -701,7 +536,7 @@ module Polars
701
536
 
702
537
  # Return a timestamp in the given time unit.
703
538
  #
704
- # @param tu ["us", "ns", "ms"]
539
+ # @param time_unit ["us", "ns", "ms"]
705
540
  # Time unit.
706
541
  #
707
542
  # @return [Series]
@@ -709,10 +544,10 @@ module Polars
709
544
  # @example
710
545
  # start = DateTime.new(2001, 1, 1)
711
546
  # stop = DateTime.new(2001, 1, 3)
712
- # date = Polars.date_range(start, stop, "1d")
547
+ # date = Polars.datetime_range(start, stop, "1d", eager: true).alias("datetime")
713
548
  # # =>
714
549
  # # shape: (3,)
715
- # # Series: '' [datetime[μs]]
550
+ # # Series: 'datetime' [datetime[ns]]
716
551
  # # [
717
552
  # # 2001-01-01 00:00:00
718
553
  # # 2001-01-02 00:00:00
@@ -740,13 +575,13 @@ module Polars
740
575
  # # 978393600000000000
741
576
  # # 978480000000000000
742
577
  # # ]
743
- def timestamp(tu = "us")
578
+ def timestamp(time_unit = "us")
744
579
  super
745
580
  end
746
581
 
747
582
  # Get the time passed since the Unix EPOCH in the give time unit.
748
583
  #
749
- # @param tu ["us", "ns", "ms", "s", "d"]
584
+ # @param time_unit ["us", "ns", "ms", "s", "d"]
750
585
  # Time unit.
751
586
  #
752
587
  # @return [Series]
@@ -754,10 +589,10 @@ module Polars
754
589
  # @example
755
590
  # start = DateTime.new(2001, 1, 1)
756
591
  # stop = DateTime.new(2001, 1, 3)
757
- # date = Polars.date_range(start, stop, "1d")
592
+ # date = Polars.datetime_range(start, stop, "1d", eager: true).alias("datetime")
758
593
  # # =>
759
594
  # # shape: (3,)
760
- # # Series: '' [datetime[μs]]
595
+ # # Series: 'datetime' [datetime[ns]]
761
596
  # # [
762
597
  # # 2001-01-01 00:00:00
763
598
  # # 2001-01-02 00:00:00
@@ -785,7 +620,7 @@ module Polars
785
620
  # # 978393600
786
621
  # # 978480000
787
622
  # # ]
788
- def epoch(tu = "us")
623
+ def epoch(time_unit = "us")
789
624
  super
790
625
  end
791
626
 
@@ -794,7 +629,7 @@ module Polars
794
629
  # This does not modify underlying data, and should be used to fix an incorrect
795
630
  # time unit.
796
631
  #
797
- # @param tu ["ns", "us", "ms"]
632
+ # @param time_unit ["ns", "us", "ms"]
798
633
  # Time unit for the `Datetime` Series.
799
634
  #
800
635
  # @return [Series]
@@ -802,10 +637,10 @@ module Polars
802
637
  # @example
803
638
  # start = DateTime.new(2001, 1, 1)
804
639
  # stop = DateTime.new(2001, 1, 3)
805
- # date = Polars.date_range(start, stop, "1d", time_unit: "ns")
640
+ # date = Polars.datetime_range(start, stop, "1d", time_unit: "ns", eager: true).alias("datetime")
806
641
  # # =>
807
642
  # # shape: (3,)
808
- # # Series: '' [datetime[ns]]
643
+ # # Series: 'datetime' [datetime[ns]]
809
644
  # # [
810
645
  # # 2001-01-01 00:00:00
811
646
  # # 2001-01-02 00:00:00
@@ -822,13 +657,13 @@ module Polars
822
657
  # # +32974-01-22 00:00:00
823
658
  # # +32976-10-18 00:00:00
824
659
  # # ]
825
- def with_time_unit(tu)
660
+ def with_time_unit(time_unit)
826
661
  super
827
662
  end
828
663
 
829
664
  # Cast the underlying data to another time unit. This may lose precision.
830
665
  #
831
- # @param tu ["ns", "us", "ms"]
666
+ # @param time_unit ["ns", "us", "ms"]
832
667
  # Time unit for the `Datetime` Series.
833
668
  #
834
669
  # @return [Series]
@@ -836,10 +671,10 @@ module Polars
836
671
  # @example
837
672
  # start = DateTime.new(2001, 1, 1)
838
673
  # stop = DateTime.new(2001, 1, 3)
839
- # date = Polars.date_range(start, stop, "1d")
674
+ # date = Polars.datetime_range(start, stop, "1d", eager: true).alias("datetime")
840
675
  # # =>
841
676
  # # shape: (3,)
842
- # # Series: '' [datetime[μs]]
677
+ # # Series: 'datetime' [datetime[ns]]
843
678
  # # [
844
679
  # # 2001-01-01 00:00:00
845
680
  # # 2001-01-02 00:00:00
@@ -867,13 +702,13 @@ module Polars
867
702
  # # 2001-01-02 00:00:00
868
703
  # # 2001-01-03 00:00:00
869
704
  # # ]
870
- def cast_time_unit(tu)
705
+ def cast_time_unit(time_unit)
871
706
  super
872
707
  end
873
708
 
874
709
  # Set time zone a Series of type Datetime.
875
710
  #
876
- # @param tz [String]
711
+ # @param time_zone [String]
877
712
  # Time zone for the `Datetime` Series.
878
713
  #
879
714
  # @return [Series]
@@ -881,10 +716,10 @@ module Polars
881
716
  # @example
882
717
  # start = DateTime.new(2020, 3, 1)
883
718
  # stop = DateTime.new(2020, 5, 1)
884
- # date = Polars.date_range(start, stop, "1mo", time_zone: "UTC")
719
+ # date = Polars.datetime_range(start, stop, "1mo", time_zone: "UTC", eager: true).alias("datetime")
885
720
  # # =>
886
721
  # # shape: (3,)
887
- # # Series: '' [datetime[μs, UTC]]
722
+ # # Series: 'datetime' [datetime[ns, UTC]]
888
723
  # # [
889
724
  # # 2020-03-01 00:00:00 UTC
890
725
  # # 2020-04-01 00:00:00 UTC
@@ -895,13 +730,13 @@ module Polars
895
730
  # date.dt.convert_time_zone("Europe/London").alias("London")
896
731
  # # =>
897
732
  # # shape: (3,)
898
- # # Series: 'London' [datetime[μs, Europe/London]]
733
+ # # Series: 'London' [datetime[ns, Europe/London]]
899
734
  # # [
900
735
  # # 2020-03-01 00:00:00 GMT
901
736
  # # 2020-04-01 01:00:00 BST
902
737
  # # 2020-05-01 01:00:00 BST
903
738
  # # ]
904
- def convert_time_zone(tz)
739
+ def convert_time_zone(time_zone)
905
740
  super
906
741
  end
907
742
 
@@ -912,8 +747,6 @@ module Polars
912
747
  #
913
748
  # @param time_zone [String]
914
749
  # Time zone for the `Datetime` Series. Pass `nil` to unset time zone.
915
- # @param use_earliest [Boolean]
916
- # Determine how to deal with ambiguous datetimes.
917
750
  # @param ambiguous [String]
918
751
  # Determine how to deal with ambiguous datetimes.
919
752
  # @param non_existent [String]
@@ -924,10 +757,10 @@ module Polars
924
757
  # @example
925
758
  # start = DateTime.new(2020, 3, 1)
926
759
  # stop = DateTime.new(2020, 5, 1)
927
- # date = Polars.date_range(start, stop, "1mo", time_zone: "UTC")
760
+ # date = Polars.datetime_range(start, stop, "1mo", time_zone: "UTC", eager: true).alias("datetime")
928
761
  # # =>
929
762
  # # shape: (3,)
930
- # # Series: '' [datetime[μs, UTC]]
763
+ # # Series: 'datetime' [datetime[ns, UTC]]
931
764
  # # [
932
765
  # # 2020-03-01 00:00:00 UTC
933
766
  # # 2020-04-01 00:00:00 UTC
@@ -938,7 +771,7 @@ module Polars
938
771
  # date.dt.epoch("s")
939
772
  # # =>
940
773
  # # shape: (3,)
941
- # # Series: '' [i64]
774
+ # # Series: 'datetime' [i64]
942
775
  # # [
943
776
  # # 1583020800
944
777
  # # 1585699200
@@ -949,7 +782,7 @@ module Polars
949
782
  # date = date.dt.convert_time_zone("Europe/London").alias("London")
950
783
  # # =>
951
784
  # # shape: (3,)
952
- # # Series: 'London' [datetime[μs, Europe/London]]
785
+ # # Series: 'London' [datetime[ns, Europe/London]]
953
786
  # # [
954
787
  # # 2020-03-01 00:00:00 GMT
955
788
  # # 2020-04-01 01:00:00 BST
@@ -971,7 +804,7 @@ module Polars
971
804
  # date = date.dt.replace_time_zone("America/New_York").alias("NYC")
972
805
  # # =>
973
806
  # # shape: (3,)
974
- # # Series: 'NYC' [datetime[μs, America/New_York]]
807
+ # # Series: 'NYC' [datetime[ns, America/New_York]]
975
808
  # # [
976
809
  # # 2020-03-01 00:00:00 EST
977
810
  # # 2020-04-01 01:00:00 EDT
@@ -988,7 +821,7 @@ module Polars
988
821
  # # 1585717200
989
822
  # # 1588309200
990
823
  # # ]
991
- def replace_time_zone(time_zone, use_earliest: nil, ambiguous: "raise", non_existent: "raise")
824
+ def replace_time_zone(time_zone, ambiguous: "raise", non_existent: "raise")
992
825
  super
993
826
  end
994
827
 
@@ -1010,39 +843,32 @@ module Polars
1010
843
  # @return [Series]
1011
844
  #
1012
845
  # @example
1013
- # date = Polars.date_range(DateTime.new(2020, 3, 1), DateTime.new(2020, 5, 1), "1mo")
1014
- # # =>
1015
- # # shape: (3,)
1016
- # # Series: '' [datetime[μs]]
1017
- # # [
1018
- # # 2020-03-01 00:00:00
1019
- # # 2020-04-01 00:00:00
1020
- # # 2020-05-01 00:00:00
1021
- # # ]
1022
- #
1023
- # @example
1024
- # date.diff.dt.days
846
+ # date = Polars.datetime_range(
847
+ # Time.utc(2020, 3, 1), Time.utc(2020, 5, 1), "1mo", eager: true
848
+ # ).alias("datetime")
849
+ # date.diff.dt.total_days
1025
850
  # # =>
1026
851
  # # shape: (3,)
1027
- # # Series: '' [i64]
852
+ # # Series: 'datetime' [i64]
1028
853
  # # [
1029
854
  # # null
1030
855
  # # 31
1031
856
  # # 30
1032
857
  # # ]
1033
- def days
858
+ def total_days
1034
859
  super
1035
860
  end
861
+ alias_method :days, :total_days
1036
862
 
1037
863
  # Extract the hours from a Duration type.
1038
864
  #
1039
865
  # @return [Series]
1040
866
  #
1041
867
  # @example
1042
- # date = Polars.date_range(DateTime.new(2020, 1, 1), DateTime.new(2020, 1, 4), "1d")
868
+ # date = Polars.datetime_range(DateTime.new(2020, 1, 1), DateTime.new(2020, 1, 4), "1d", time_unit: "us", eager: true).alias("datetime")
1043
869
  # # =>
1044
870
  # # shape: (4,)
1045
- # # Series: '' [datetime[μs]]
871
+ # # Series: 'datetime' [datetime[μs]]
1046
872
  # # [
1047
873
  # # 2020-01-01 00:00:00
1048
874
  # # 2020-01-02 00:00:00
@@ -1051,29 +877,30 @@ module Polars
1051
877
  # # ]
1052
878
  #
1053
879
  # @example
1054
- # date.diff.dt.hours
880
+ # date.diff.dt.total_hours
1055
881
  # # =>
1056
882
  # # shape: (4,)
1057
- # # Series: '' [i64]
883
+ # # Series: 'datetime' [i64]
1058
884
  # # [
1059
885
  # # null
1060
886
  # # 24
1061
887
  # # 24
1062
888
  # # 24
1063
889
  # # ]
1064
- def hours
890
+ def total_hours
1065
891
  super
1066
892
  end
893
+ alias_method :hours, :total_hours
1067
894
 
1068
895
  # Extract the minutes from a Duration type.
1069
896
  #
1070
897
  # @return [Series]
1071
898
  #
1072
899
  # @example
1073
- # date = Polars.date_range(DateTime.new(2020, 1, 1), DateTime.new(2020, 1, 4), "1d")
900
+ # date = Polars.datetime_range(DateTime.new(2020, 1, 1), DateTime.new(2020, 1, 4), "1d", time_unit: "us", eager: true).alias("datetime")
1074
901
  # # =>
1075
902
  # # shape: (4,)
1076
- # # Series: '' [datetime[μs]]
903
+ # # Series: 'datetime' [datetime[μs]]
1077
904
  # # [
1078
905
  # # 2020-01-01 00:00:00
1079
906
  # # 2020-01-02 00:00:00
@@ -1082,31 +909,32 @@ module Polars
1082
909
  # # ]
1083
910
  #
1084
911
  # @example
1085
- # date.diff.dt.minutes
912
+ # date.diff.dt.total_minutes
1086
913
  # # =>
1087
914
  # # shape: (4,)
1088
- # # Series: '' [i64]
915
+ # # Series: 'datetime' [i64]
1089
916
  # # [
1090
917
  # # null
1091
918
  # # 1440
1092
919
  # # 1440
1093
920
  # # 1440
1094
921
  # # ]
1095
- def minutes
922
+ def total_minutes
1096
923
  super
1097
924
  end
925
+ alias_method :minutes, :total_minutes
1098
926
 
1099
927
  # Extract the seconds from a Duration type.
1100
928
  #
1101
929
  # @return [Series]
1102
930
  #
1103
931
  # @example
1104
- # date = Polars.date_range(
1105
- # DateTime.new(2020, 1, 1), DateTime.new(2020, 1, 1, 0, 4, 0), "1m"
1106
- # )
932
+ # date = Polars.datetime_range(
933
+ # DateTime.new(2020, 1, 1), DateTime.new(2020, 1, 1, 0, 4, 0), "1m", time_unit: "us", eager: true
934
+ # ).alias("datetime")
1107
935
  # # =>
1108
936
  # # shape: (5,)
1109
- # # Series: '' [datetime[μs]]
937
+ # # Series: 'datetime' [datetime[μs]]
1110
938
  # # [
1111
939
  # # 2020-01-01 00:00:00
1112
940
  # # 2020-01-01 00:01:00
@@ -1116,10 +944,10 @@ module Polars
1116
944
  # # ]
1117
945
  #
1118
946
  # @example
1119
- # date.diff.dt.seconds
947
+ # date.diff.dt.total_seconds
1120
948
  # # =>
1121
949
  # # shape: (5,)
1122
- # # Series: '' [i64]
950
+ # # Series: 'datetime' [i64]
1123
951
  # # [
1124
952
  # # null
1125
953
  # # 60
@@ -1127,21 +955,22 @@ module Polars
1127
955
  # # 60
1128
956
  # # 60
1129
957
  # # ]
1130
- def seconds
958
+ def total_seconds
1131
959
  super
1132
960
  end
961
+ alias_method :seconds, :total_seconds
1133
962
 
1134
963
  # Extract the milliseconds from a Duration type.
1135
964
  #
1136
965
  # @return [Series]
1137
966
  #
1138
967
  # @example
1139
- # date = Polars.date_range(
1140
- # DateTime.new(2020, 1, 1), DateTime.new(2020, 1, 1, 0, 0, 1, 0), "1ms"
1141
- # )[0..2]
968
+ # date = Polars.datetime_range(
969
+ # DateTime.new(2020, 1, 1), DateTime.new(2020, 1, 1, 0, 0, 1, 0), "1ms", time_unit: "us", eager: true
970
+ # ).alias("datetime")[0..2]
1142
971
  # # =>
1143
972
  # # shape: (3,)
1144
- # # Series: '' [datetime[μs]]
973
+ # # Series: 'datetime' [datetime[μs]]
1145
974
  # # [
1146
975
  # # 2020-01-01 00:00:00
1147
976
  # # 2020-01-01 00:00:00.001
@@ -1149,30 +978,31 @@ module Polars
1149
978
  # # ]
1150
979
  #
1151
980
  # @example
1152
- # date.diff.dt.milliseconds
981
+ # date.diff.dt.total_milliseconds
1153
982
  # # =>
1154
983
  # # shape: (3,)
1155
- # # Series: '' [i64]
984
+ # # Series: 'datetime' [i64]
1156
985
  # # [
1157
986
  # # null
1158
987
  # # 1
1159
988
  # # 1
1160
989
  # # ]
1161
- def milliseconds
990
+ def total_milliseconds
1162
991
  super
1163
992
  end
993
+ alias_method :milliseconds, :total_milliseconds
1164
994
 
1165
995
  # Extract the microseconds from a Duration type.
1166
996
  #
1167
997
  # @return [Series]
1168
998
  #
1169
999
  # @example
1170
- # date = Polars.date_range(
1171
- # DateTime.new(2020, 1, 1), DateTime.new(2020, 1, 1, 0, 0, 1, 0), "1ms"
1172
- # )[0..2]
1000
+ # date = Polars.datetime_range(
1001
+ # DateTime.new(2020, 1, 1), DateTime.new(2020, 1, 1, 0, 0, 1, 0), "1ms", time_unit: "us", eager: true
1002
+ # ).alias("datetime")[0..2]
1173
1003
  # # =>
1174
1004
  # # shape: (3,)
1175
- # # Series: '' [datetime[μs]]
1005
+ # # Series: 'datetime' [datetime[μs]]
1176
1006
  # # [
1177
1007
  # # 2020-01-01 00:00:00
1178
1008
  # # 2020-01-01 00:00:00.001
@@ -1180,30 +1010,31 @@ module Polars
1180
1010
  # # ]
1181
1011
  #
1182
1012
  # @example
1183
- # date.diff.dt.microseconds
1013
+ # date.diff.dt.total_microseconds
1184
1014
  # # =>
1185
1015
  # # shape: (3,)
1186
- # # Series: '' [i64]
1016
+ # # Series: 'datetime' [i64]
1187
1017
  # # [
1188
1018
  # # null
1189
1019
  # # 1000
1190
1020
  # # 1000
1191
1021
  # # ]
1192
- def microseconds
1022
+ def total_microseconds
1193
1023
  super
1194
1024
  end
1025
+ alias_method :microseconds, :total_microseconds
1195
1026
 
1196
1027
  # Extract the nanoseconds from a Duration type.
1197
1028
  #
1198
1029
  # @return [Series]
1199
1030
  #
1200
1031
  # @example
1201
- # date = Polars.date_range(
1202
- # DateTime.new(2020, 1, 1), DateTime.new(2020, 1, 1, 0, 0, 1, 0), "1ms"
1203
- # )[0..2]
1032
+ # date = Polars.datetime_range(
1033
+ # DateTime.new(2020, 1, 1), DateTime.new(2020, 1, 1, 0, 0, 1, 0), "1ms", time_unit: "us", eager: true
1034
+ # ).alias("datetime")[0..2]
1204
1035
  # # =>
1205
1036
  # # shape: (3,)
1206
- # # Series: '' [datetime[μs]]
1037
+ # # Series: 'datetime' [datetime[μs]]
1207
1038
  # # [
1208
1039
  # # 2020-01-01 00:00:00
1209
1040
  # # 2020-01-01 00:00:00.001
@@ -1211,18 +1042,19 @@ module Polars
1211
1042
  # # ]
1212
1043
  #
1213
1044
  # @example
1214
- # date.diff.dt.nanoseconds
1045
+ # date.diff.dt.total_nanoseconds
1215
1046
  # # =>
1216
1047
  # # shape: (3,)
1217
- # # Series: '' [i64]
1048
+ # # Series: 'datetime' [i64]
1218
1049
  # # [
1219
1050
  # # null
1220
1051
  # # 1000000
1221
1052
  # # 1000000
1222
1053
  # # ]
1223
- def nanoseconds
1054
+ def total_nanoseconds
1224
1055
  super
1225
1056
  end
1057
+ alias_method :nanoseconds, :total_nanoseconds
1226
1058
 
1227
1059
  # Offset this date by a relative time offset.
1228
1060
  #
@@ -1248,10 +1080,12 @@ module Polars
1248
1080
  # @return [Series]
1249
1081
  #
1250
1082
  # @example
1251
- # dates = Polars.date_range(DateTime.new(2000, 1, 1), DateTime.new(2005, 1, 1), "1y")
1083
+ # dates = Polars.datetime_range(
1084
+ # DateTime.new(2000, 1, 1), DateTime.new(2005, 1, 1), "1y", eager: true
1085
+ # ).alias("datetime")
1252
1086
  # # =>
1253
1087
  # # shape: (6,)
1254
- # # Series: '' [datetime[μs]]
1088
+ # # Series: 'datetime' [datetime[ns]]
1255
1089
  # # [
1256
1090
  # # 2000-01-01 00:00:00
1257
1091
  # # 2001-01-01 00:00:00
@@ -1265,7 +1099,7 @@ module Polars
1265
1099
  # dates.dt.offset_by("1y").alias("date_plus_1y")
1266
1100
  # # =>
1267
1101
  # # shape: (6,)
1268
- # # Series: 'date_plus_1y' [datetime[μs]]
1102
+ # # Series: 'date_plus_1y' [datetime[ns]]
1269
1103
  # # [
1270
1104
  # # 2001-01-01 00:00:00
1271
1105
  # # 2002-01-01 00:00:00
@@ -1279,7 +1113,7 @@ module Polars
1279
1113
  # dates.dt.offset_by("-1y2mo").alias("date_minus_1y_2mon")
1280
1114
  # # =>
1281
1115
  # # shape: (6,)
1282
- # # Series: 'date_minus_1y_2mon' [datetime[μs]]
1116
+ # # Series: 'date_minus_1y_2mon' [datetime[ns]]
1283
1117
  # # [
1284
1118
  # # 1998-11-01 00:00:00
1285
1119
  # # 1999-11-01 00:00:00
@@ -1314,79 +1148,9 @@ module Polars
1314
1148
  #
1315
1149
  # @param every [String]
1316
1150
  # Every interval start and period length.
1317
- # @param offset [String]
1318
- # Offset the window.
1319
1151
  #
1320
1152
  # @return [Series]
1321
- #
1322
- # @example
1323
- # start = DateTime.new(2001, 1, 1)
1324
- # stop = DateTime.new(2001, 1, 2)
1325
- # s = Polars.date_range(start, stop, "165m", name: "dates")
1326
- # # =>
1327
- # # shape: (9,)
1328
- # # Series: 'dates' [datetime[μs]]
1329
- # # [
1330
- # # 2001-01-01 00:00:00
1331
- # # 2001-01-01 02:45:00
1332
- # # 2001-01-01 05:30:00
1333
- # # 2001-01-01 08:15:00
1334
- # # 2001-01-01 11:00:00
1335
- # # 2001-01-01 13:45:00
1336
- # # 2001-01-01 16:30:00
1337
- # # 2001-01-01 19:15:00
1338
- # # 2001-01-01 22:00:00
1339
- # # ]
1340
- #
1341
- # @example
1342
- # s.dt.truncate("1h")
1343
- # # =>
1344
- # # shape: (9,)
1345
- # # Series: 'dates' [datetime[μs]]
1346
- # # [
1347
- # # 2001-01-01 00:00:00
1348
- # # 2001-01-01 02:00:00
1349
- # # 2001-01-01 05:00:00
1350
- # # 2001-01-01 08:00:00
1351
- # # 2001-01-01 11:00:00
1352
- # # 2001-01-01 13:00:00
1353
- # # 2001-01-01 16:00:00
1354
- # # 2001-01-01 19:00:00
1355
- # # 2001-01-01 22:00:00
1356
- # # ]
1357
- #
1358
- # @example
1359
- # start = DateTime.new(2001, 1, 1)
1360
- # stop = DateTime.new(2001, 1, 1, 1)
1361
- # s = Polars.date_range(start, stop, "10m", name: "dates")
1362
- # # =>
1363
- # # shape: (7,)
1364
- # # Series: 'dates' [datetime[μs]]
1365
- # # [
1366
- # # 2001-01-01 00:00:00
1367
- # # 2001-01-01 00:10:00
1368
- # # 2001-01-01 00:20:00
1369
- # # 2001-01-01 00:30:00
1370
- # # 2001-01-01 00:40:00
1371
- # # 2001-01-01 00:50:00
1372
- # # 2001-01-01 01:00:00
1373
- # # ]
1374
- #
1375
- # @example
1376
- # s.dt.truncate("30m")
1377
- # # =>
1378
- # # shape: (7,)
1379
- # # Series: 'dates' [datetime[μs]]
1380
- # # [
1381
- # # 2001-01-01 00:00:00
1382
- # # 2001-01-01 00:00:00
1383
- # # 2001-01-01 00:00:00
1384
- # # 2001-01-01 00:30:00
1385
- # # 2001-01-01 00:30:00
1386
- # # 2001-01-01 00:30:00
1387
- # # 2001-01-01 01:00:00
1388
- # # ]
1389
- def truncate(every, offset: nil, use_earliest: nil)
1153
+ def truncate(every)
1390
1154
  super
1391
1155
  end
1392
1156
 
@@ -1415,69 +1179,108 @@ module Polars
1415
1179
  #
1416
1180
  # @param every [String]
1417
1181
  # Every interval start and period length.
1418
- # @param offset [String]
1419
- # Offset the window.
1420
1182
  #
1421
1183
  # @return [Series]
1422
1184
  #
1423
1185
  # @note
1424
1186
  # This functionality is currently experimental and may
1425
1187
  # change without it being considered a breaking change.
1188
+ def round(every)
1189
+ super
1190
+ end
1191
+
1192
+ # Roll backward to the first day of the month.
1193
+ #
1194
+ # @return [Series]
1426
1195
  #
1427
1196
  # @example
1428
- # start = DateTime.new(2001, 1, 1)
1429
- # stop = DateTime.new(2001, 1, 2)
1430
- # s = Polars.date_range(start, stop, "165m", name: "dates")
1197
+ # s = Polars.datetime_range(
1198
+ # DateTime.new(2000, 1, 2, 2), DateTime.new(2000, 4, 2, 2), "1mo", time_unit: "us", eager: true
1199
+ # ).alias("datetime")
1200
+ # s.dt.month_start
1431
1201
  # # =>
1432
- # # shape: (9,)
1433
- # # Series: 'dates' [datetime[μs]]
1202
+ # # shape: (4,)
1203
+ # # Series: 'datetime' [datetime[μs]]
1434
1204
  # # [
1435
- # # 2001-01-01 00:00:00
1436
- # # 2001-01-01 02:45:00
1437
- # # 2001-01-01 05:30:00
1438
- # # 2001-01-01 08:15:00
1439
- # # 2001-01-01 11:00:00
1440
- # # 2001-01-01 13:45:00
1441
- # # 2001-01-01 16:30:00
1442
- # # 2001-01-01 19:15:00
1443
- # # 2001-01-01 22:00:00
1205
+ # # 2000-01-01 02:00:00
1206
+ # # 2000-02-01 02:00:00
1207
+ # # 2000-03-01 02:00:00
1208
+ # # 2000-04-01 02:00:00
1209
+ # # ]
1210
+ def month_start
1211
+ super
1212
+ end
1213
+
1214
+ # Roll forward to the last day of the month.
1215
+ #
1216
+ # @return [Series]
1217
+ #
1218
+ # @example
1219
+ # s = Polars.datetime_range(
1220
+ # DateTime.new(2000, 1, 2, 2), DateTime.new(2000, 4, 2, 2), "1mo", time_unit: "us", eager: true
1221
+ # ).alias("datetime")
1222
+ # s.dt.month_end
1223
+ # # =>
1224
+ # # shape: (4,)
1225
+ # # Series: 'datetime' [datetime[μs]]
1226
+ # # [
1227
+ # # 2000-01-31 02:00:00
1228
+ # # 2000-02-29 02:00:00
1229
+ # # 2000-03-31 02:00:00
1230
+ # # 2000-04-30 02:00:00
1444
1231
  # # ]
1232
+ def month_end
1233
+ super
1234
+ end
1235
+
1236
+ # Base offset from UTC.
1237
+ #
1238
+ # This is usually constant for all datetimes in a given time zone, but
1239
+ # may vary in the rare case that a country switches time zone, like
1240
+ # Samoa (Apia) did at the end of 2011.
1241
+ #
1242
+ # @return [Series]
1445
1243
  #
1446
1244
  # @example
1447
- # s.dt.round("1h")
1245
+ # s = Polars.datetime_range(
1246
+ # DateTime.new(2011, 12, 29),
1247
+ # DateTime.new(2012, 1, 1),
1248
+ # "2d",
1249
+ # time_zone: "Pacific/Apia",
1250
+ # eager: true,
1251
+ # ).alias("datetime")
1252
+ # s.dt.base_utc_offset
1448
1253
  # # =>
1449
- # # shape: (9,)
1450
- # # Series: 'dates' [datetime[μs]]
1254
+ # # shape: (2,)
1255
+ # # Series: 'datetime' [duration[ms]]
1451
1256
  # # [
1452
- # # 2001-01-01 00:00:00
1453
- # # 2001-01-01 03:00:00
1454
- # # 2001-01-01 06:00:00
1455
- # # 2001-01-01 08:00:00
1456
- # # 2001-01-01 11:00:00
1457
- # # 2001-01-01 14:00:00
1458
- # # 2001-01-01 17:00:00
1459
- # # 2001-01-01 19:00:00
1460
- # # 2001-01-01 22:00:00
1257
+ # # -11h
1258
+ # # 13h
1461
1259
  # # ]
1260
+ def base_utc_offset
1261
+ super
1262
+ end
1263
+
1264
+ # Additional offset currently in effect (typically due to daylight saving time).
1265
+ #
1266
+ # @return [Series]
1462
1267
  #
1463
1268
  # @example
1464
- # start = DateTime.new(2001, 1, 1)
1465
- # stop = DateTime.new(2001, 1, 1, 1)
1466
- # s = Polars.date_range(start, stop, "10m", name: "dates")
1467
- # s.dt.round("30m")
1269
+ # s = Polars.datetime_range(
1270
+ # DateTime.new(2020, 10, 25),
1271
+ # DateTime.new(2020, 10, 26),
1272
+ # time_zone: "Europe/London",
1273
+ # eager: true,
1274
+ # ).alias("datetime")
1275
+ # s.dt.dst_offset
1468
1276
  # # =>
1469
- # # shape: (7,)
1470
- # # Series: 'dates' [datetime[μs]]
1277
+ # # shape: (2,)
1278
+ # # Series: 'datetime' [duration[ms]]
1471
1279
  # # [
1472
- # # 2001-01-01 00:00:00
1473
- # # 2001-01-01 00:00:00
1474
- # # 2001-01-01 00:30:00
1475
- # # 2001-01-01 00:30:00
1476
- # # 2001-01-01 00:30:00
1477
- # # 2001-01-01 01:00:00
1478
- # # 2001-01-01 01:00:00
1280
+ # # 1h
1281
+ # # 0ms
1479
1282
  # # ]
1480
- def round(every, offset: nil)
1283
+ def dst_offset
1481
1284
  super
1482
1285
  end
1483
1286
  end