lib/polars/lazy_frame.rb in polars-df-0.1.0 vs lib/polars/lazy_frame.rb in polars-df-0.1.1
- old
+ new
@@ -6,10 +6,55 @@
ldf = LazyFrame.allocate
ldf._ldf = rb_ldf
ldf
end
+ # def columns
+ # end
+
+ # def dtypes
+ # end
+
+ # def schema
+ # end
+
+ # def width
+ # end
+
+ # def include?(key)
+ # end
+
+ # clone handled by initialize_copy
+
+ # def [](item)
+ # end
+
+ # def to_s
+ # end
+ # alias_method :inspect, :to_s
+
+ # def write_json
+ # end
+
+ # def pipe
+ # end
+
+ # def describe_plan
+ # end
+
+ # def describe_optimized_plan
+ # end
+
+ # def show_graph
+ # end
+
+ # def sort
+ # end
+
+ # def profile
+ # end
+
def collect(
type_coercion: true,
predicate_pushdown: true,
projection_pushdown: true,
simplify_expression: true,
@@ -40,29 +85,51 @@
allow_streaming
)
Utils.wrap_df(ldf.collect)
end
+ # def fetch
+ # end
+
+ def lazy
+ self
+ end
+
+ # def cache
+ # end
+
+ # def cleared
+ # end
+
def filter(predicate)
- self.class._from_rbldf(
+ _from_rbldf(
_ldf.filter(
Utils.expr_to_lit_or_expr(predicate, str_to_lit: false)._rbexpr
)
)
end
def select(exprs)
exprs = Utils.selection_to_rbexpr_list(exprs)
- self.class._from_rbldf(_ldf.select(exprs))
+ _from_rbldf(_ldf.select(exprs))
end
def groupby(by, maintain_order: false)
rbexprs_by = Utils.selection_to_rbexpr_list(by)
lgb = _ldf.groupby(rbexprs_by, maintain_order)
LazyGroupBy.new(lgb, self.class)
end
+ # def groupby_rolling
+ # end
+
+ # def groupby_dynamic
+ # end
+
+ # def join_asof
+ # end
+
def join(
other,
left_on: nil,
right_on: nil,
on: nil,
@@ -74,11 +141,11 @@
if !other.is_a?(LazyFrame)
raise ArgumentError, "Expected a `LazyFrame` as join table, got #{other.class.name}"
end
if how == "cross"
- return self.class._from_rbldf(
+ return _from_rbldf(
_ldf.join(
other._ldf, [], [], allow_parallel, force_parallel, how, suffix
)
)
end
@@ -92,11 +159,11 @@
rbexprs_right = Utils.selection_to_rbexpr_list(right_on)
else
raise ArgumentError, "must specify `on` OR `left_on` and `right_on`"
end
- self.class._from_rbldf(
+ _from_rbldf(
self._ldf.join(
other._ldf,
rbexprs_left,
rbexprs_right,
allow_parallel,
@@ -121,19 +188,130 @@
exprs.each do |e|
case e
when Expr
rbexprs << e._rbexpr
when Series
- rbexprs = Internal.lit(e)._rbexpr
+ rbexprs = Utils.lit(e)._rbexpr
else
raise ArgumentError, "Expected an expression, got #{e}"
end
end
- self.class._from_rbldf(_ldf.with_columns(rbexprs))
+ _from_rbldf(_ldf.with_columns(rbexprs))
end
+ # def with_context
+ # end
+
def with_column(column)
with_columns([column])
+ end
+
+ # def drop
+ # end
+
+ def rename(mapping)
+ existing = mapping.keys
+ _new = mapping.values
+ _from_rbldf(_ldf.rename(existing, _new))
+ end
+
+ # def reverse
+ # end
+
+ # def shift
+ # end
+
+ # def shift_and_fill
+ # end
+
+ # def slice
+ # end
+
+ # def limit
+ # end
+
+ # def head
+ # end
+
+ # def tail
+ # end
+
+ # def last
+ # end
+
+ # def first
+ # end
+
+ # def with_row_count
+ # end
+
+ # def take_every
+ # end
+
+ # def fill_null
+ # end
+
+ def fill_nan(fill_value)
+ if !fill_value.is_a?(Expr)
+ fill_value = Utils.lit(fill_value)
+ end
+ _from_rbldf(_ldf.fill_nan(fill_value._rbexpr))
+ end
+
+ # def std
+ # end
+
+ # def var
+ # end
+
+ # def max
+ # end
+
+ # def min
+ # end
+
+ # def sum
+ # end
+
+ # def mean
+ # end
+
+ # def median
+ # end
+
+ # def quantile
+ # end
+
+ # def explode
+ # end
+
+ # def unique
+ # end
+
+ # def drop_nulls
+ # end
+
+ # def melt
+ # end
+
+ # def map
+ # end
+
+ # def interpolate
+ # end
+
+ # def unnest
+ # end
+
+ private
+
+ def initialize_copy(other)
+ super
+ self._ldf = _ldf._clone
+ end
+
+ def _from_rbldf(rb_ldf)
+ self.class._from_rbldf(rb_ldf)
end
end
end