polars-df 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,27 @@
1
+ module Polars
2
+ class StructExpr
3
+ attr_accessor :_rbexpr
4
+
5
+ def initialize(expr)
6
+ self._rbexpr = expr._rbexpr
7
+ end
8
+
9
+ def [](item)
10
+ if item.is_a?(String)
11
+ field(item)
12
+ elsif item.is_a?(Integer)
13
+ Utils.wrap_expr(_rbexpr.struct_field_by_index(item))
14
+ else
15
+ raise ArgumentError, "expected type Integer or String, got #{item.class.name}"
16
+ end
17
+ end
18
+
19
+ def field(name)
20
+ Utils.wrap_expr(_rbexpr.struct_field_by_name(name))
21
+ end
22
+
23
+ def rename_fields(names)
24
+ Utils.wrap_expr(_rbexpr.struct_rename_fields(names))
25
+ end
26
+ end
27
+ end
data/lib/polars/utils.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  module Polars
2
2
  module Utils
3
+ DTYPE_TEMPORAL_UNITS = ["ns", "us", "ms"]
4
+
3
5
  def self.wrap_s(s)
4
6
  Series._from_rbseries(s)
5
7
  end
@@ -43,5 +45,30 @@ module Polars
43
45
  def self.format_path(path)
44
46
  File.expand_path(path)
45
47
  end
48
+
49
+ # TODO fix
50
+ def self.is_polars_dtype(data_type)
51
+ true
52
+ end
53
+
54
+ # TODO fix
55
+ def self.rb_type_to_dtype(dtype)
56
+ dtype.to_s
57
+ end
58
+
59
+ def self.scale_bytes(sz, to:)
60
+ scaling_factor = {
61
+ "b" => 1,
62
+ "k" => 1024,
63
+ "m" => 1024 ** 2,
64
+ "g" => 1024 ** 3,
65
+ "t" => 1024 ** 4,
66
+ }[to[0]]
67
+ if scaling_factor > 1
68
+ sz / scaling_factor.to_f
69
+ else
70
+ sz
71
+ end
72
+ end
46
73
  end
47
74
  end
@@ -1,3 +1,3 @@
1
1
  module Polars
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/polars.rb CHANGED
@@ -2,15 +2,20 @@
2
2
  require "polars/polars"
3
3
 
4
4
  # modules
5
+ require "polars/cat_expr"
5
6
  require "polars/data_frame"
7
+ require "polars/date_time_expr"
6
8
  require "polars/expr"
7
9
  require "polars/functions"
10
+ require "polars/io"
8
11
  require "polars/lazy_frame"
9
12
  require "polars/lazy_functions"
10
13
  require "polars/lazy_group_by"
11
- require "polars/io"
14
+ require "polars/list_expr"
15
+ require "polars/meta_expr"
12
16
  require "polars/series"
13
17
  require "polars/string_expr"
18
+ require "polars/struct_expr"
14
19
  require "polars/utils"
15
20
  require "polars/version"
16
21
  require "polars/when"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polars-df
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-22 00:00:00.000000000 Z
11
+ date: 2022-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rb_sys
@@ -32,6 +32,8 @@ extensions:
32
32
  extra_rdoc_files: []
33
33
  files:
34
34
  - CHANGELOG.md
35
+ - Cargo.lock
36
+ - Cargo.toml
35
37
  - LICENSE.txt
36
38
  - README.md
37
39
  - ext/polars/Cargo.toml
@@ -42,21 +44,27 @@ files:
42
44
  - ext/polars/src/file.rs
43
45
  - ext/polars/src/lazy/dataframe.rs
44
46
  - ext/polars/src/lazy/dsl.rs
47
+ - ext/polars/src/lazy/meta.rs
45
48
  - ext/polars/src/lazy/mod.rs
46
49
  - ext/polars/src/lazy/utils.rs
47
50
  - ext/polars/src/lib.rs
48
51
  - ext/polars/src/series.rs
49
52
  - lib/polars-df.rb
50
53
  - lib/polars.rb
54
+ - lib/polars/cat_expr.rb
51
55
  - lib/polars/data_frame.rb
56
+ - lib/polars/date_time_expr.rb
52
57
  - lib/polars/expr.rb
53
58
  - lib/polars/functions.rb
54
59
  - lib/polars/io.rb
55
60
  - lib/polars/lazy_frame.rb
56
61
  - lib/polars/lazy_functions.rb
57
62
  - lib/polars/lazy_group_by.rb
63
+ - lib/polars/list_expr.rb
64
+ - lib/polars/meta_expr.rb
58
65
  - lib/polars/series.rb
59
66
  - lib/polars/string_expr.rb
67
+ - lib/polars/struct_expr.rb
60
68
  - lib/polars/utils.rb
61
69
  - lib/polars/version.rb
62
70
  - lib/polars/when.rb