polars-df 0.9.0-arm64-darwin → 0.11.0-arm64-darwin
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/Cargo.lock +144 -57
- data/LICENSE-THIRD-PARTY.txt +629 -29
- data/README.md +7 -6
- data/lib/polars/3.1/polars.bundle +0 -0
- data/lib/polars/3.2/polars.bundle +0 -0
- data/lib/polars/3.3/polars.bundle +0 -0
- data/lib/polars/array_expr.rb +6 -2
- data/lib/polars/batched_csv_reader.rb +11 -3
- data/lib/polars/convert.rb +6 -1
- data/lib/polars/data_frame.rb +225 -370
- data/lib/polars/date_time_expr.rb +11 -4
- data/lib/polars/date_time_name_space.rb +14 -4
- data/lib/polars/dynamic_group_by.rb +2 -2
- data/lib/polars/exceptions.rb +4 -0
- data/lib/polars/expr.rb +1171 -54
- data/lib/polars/functions/lazy.rb +3 -3
- data/lib/polars/functions/range/date_range.rb +92 -0
- data/lib/polars/functions/range/datetime_range.rb +149 -0
- data/lib/polars/functions/range/time_range.rb +141 -0
- data/lib/polars/functions/whenthen.rb +74 -5
- data/lib/polars/group_by.rb +88 -23
- data/lib/polars/io/avro.rb +24 -0
- data/lib/polars/{io.rb → io/csv.rb} +307 -489
- data/lib/polars/io/database.rb +73 -0
- data/lib/polars/io/ipc.rb +247 -0
- data/lib/polars/io/json.rb +18 -0
- data/lib/polars/io/ndjson.rb +69 -0
- data/lib/polars/io/parquet.rb +226 -0
- data/lib/polars/lazy_frame.rb +55 -195
- data/lib/polars/lazy_group_by.rb +100 -3
- data/lib/polars/list_expr.rb +6 -2
- data/lib/polars/rolling_group_by.rb +2 -2
- data/lib/polars/series.rb +14 -12
- data/lib/polars/string_expr.rb +38 -36
- data/lib/polars/utils.rb +89 -1
- data/lib/polars/version.rb +1 -1
- data/lib/polars/whenthen.rb +83 -0
- data/lib/polars.rb +10 -3
- metadata +13 -6
- data/lib/polars/when.rb +0 -16
- data/lib/polars/when_then.rb +0 -19
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
# Polars
|
1
|
+
# Ruby Polars
|
2
2
|
|
3
3
|
:fire: Blazingly fast DataFrames for Ruby, powered by [Polars](https://github.com/pola-rs/polars)
|
4
4
|
|
5
|
-
[![Build Status](https://github.com/ankane/polars
|
5
|
+
[![Build Status](https://github.com/ankane/ruby-polars/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/ruby-polars/actions)
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -420,17 +420,18 @@ View the [changelog](CHANGELOG.md)
|
|
420
420
|
|
421
421
|
Everyone is encouraged to help improve this project. Here are a few ways you can help:
|
422
422
|
|
423
|
-
- [Report bugs](https://github.com/ankane/polars
|
424
|
-
- Fix bugs and [submit pull requests](https://github.com/ankane/polars
|
423
|
+
- [Report bugs](https://github.com/ankane/ruby-polars/issues)
|
424
|
+
- Fix bugs and [submit pull requests](https://github.com/ankane/ruby-polars/pulls)
|
425
425
|
- Write, clarify, or fix documentation
|
426
426
|
- Suggest or add new features
|
427
427
|
|
428
428
|
To get started with development:
|
429
429
|
|
430
430
|
```sh
|
431
|
-
git clone https://github.com/ankane/polars
|
432
|
-
cd polars
|
431
|
+
git clone https://github.com/ankane/ruby-polars.git
|
432
|
+
cd ruby-polars
|
433
433
|
bundle install
|
434
434
|
bundle exec rake compile
|
435
435
|
bundle exec rake test
|
436
|
+
bundle exec rake test:docs
|
436
437
|
```
|
Binary file
|
Binary file
|
Binary file
|
data/lib/polars/array_expr.rb
CHANGED
@@ -333,6 +333,10 @@ module Polars
|
|
333
333
|
#
|
334
334
|
# @param index [Integer]
|
335
335
|
# Index to return per sub-array
|
336
|
+
# @param null_on_oob [Boolean]
|
337
|
+
# Behavior if an index is out of bounds:
|
338
|
+
# true -> set as null
|
339
|
+
# false -> raise an error
|
336
340
|
#
|
337
341
|
# @return [Expr]
|
338
342
|
#
|
@@ -353,9 +357,9 @@ module Polars
|
|
353
357
|
# # │ [4, 5, 6] ┆ -2 ┆ 5 │
|
354
358
|
# # │ [7, 8, 9] ┆ 4 ┆ null │
|
355
359
|
# # └───────────────┴─────┴──────┘
|
356
|
-
def get(index)
|
360
|
+
def get(index, null_on_oob: true)
|
357
361
|
index = Utils.parse_as_expression(index)
|
358
|
-
Utils.wrap_expr(_rbexpr.arr_get(index))
|
362
|
+
Utils.wrap_expr(_rbexpr.arr_get(index, null_on_oob))
|
359
363
|
end
|
360
364
|
|
361
365
|
# Get the first value of the sub-arrays.
|
@@ -13,6 +13,7 @@ module Polars
|
|
13
13
|
skip_rows: 0,
|
14
14
|
dtypes: nil,
|
15
15
|
null_values: nil,
|
16
|
+
missing_utf8_is_empty_string: false,
|
16
17
|
ignore_errors: false,
|
17
18
|
parse_dates: false,
|
18
19
|
n_threads: nil,
|
@@ -27,10 +28,13 @@ module Polars
|
|
27
28
|
row_count_offset: 0,
|
28
29
|
sample_size: 1024,
|
29
30
|
eol_char: "\n",
|
30
|
-
new_columns: nil
|
31
|
+
new_columns: nil,
|
32
|
+
raise_if_empty: true,
|
33
|
+
truncate_ragged_lines: false,
|
34
|
+
decimal_comma: false
|
31
35
|
)
|
32
36
|
if Utils.pathlike?(file)
|
33
|
-
path = Utils.
|
37
|
+
path = Utils.normalize_filepath(file)
|
34
38
|
end
|
35
39
|
|
36
40
|
dtype_list = nil
|
@@ -71,11 +75,15 @@ module Polars
|
|
71
75
|
comment_char,
|
72
76
|
quote_char,
|
73
77
|
processed_null_values,
|
78
|
+
missing_utf8_is_empty_string,
|
74
79
|
parse_dates,
|
75
80
|
skip_rows_after_header,
|
76
81
|
Utils._prepare_row_count_args(row_count_name, row_count_offset),
|
77
82
|
sample_size,
|
78
|
-
eol_char
|
83
|
+
eol_char,
|
84
|
+
raise_if_empty,
|
85
|
+
truncate_ragged_lines,
|
86
|
+
decimal_comma
|
79
87
|
)
|
80
88
|
self.new_columns = new_columns
|
81
89
|
end
|
data/lib/polars/convert.rb
CHANGED
@@ -27,7 +27,12 @@ module Polars
|
|
27
27
|
# # │ 2 ┆ 4 │
|
28
28
|
# # └─────┴─────┘
|
29
29
|
def from_hash(data, schema: nil, columns: nil)
|
30
|
-
|
30
|
+
Utils.wrap_df(
|
31
|
+
DataFrame.hash_to_rbdf(
|
32
|
+
data,
|
33
|
+
schema: schema || columns
|
34
|
+
)
|
35
|
+
)
|
31
36
|
end
|
32
37
|
|
33
38
|
# Construct a DataFrame from a sequence of dictionaries. This operation clones data.
|