Class: Polars::Categorical

Inherits:
DataType show all
Defined in:
lib/polars/data_types.rb

Overview

A categorical encoding of a set of strings.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ordering = "physical", **kwargs) ⇒ Categorical

Returns a new instance of Categorical.



343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
# File 'lib/polars/data_types.rb', line 343

def initialize(ordering = "physical", **kwargs)
  if ordering.is_a?(Categories)
    @ordering = "lexical"
    @categories = ordering
    # assert kwargs.length == 0
    return
  end

  @ordering = "lexical"
  if kwargs[:categories]
    # assert kwargs.length == 1
    @categories = kwargs[:categories]
  else
    # assert kwargs.length == 0
    @categories = Categories.new
  end
end

Instance Attribute Details

#categoriesObject (readonly)

Returns the value of attribute categories.



341
342
343
# File 'lib/polars/data_types.rb', line 341

def categories
  @categories
end

#orderingObject (readonly)

Returns the value of attribute ordering.



341
342
343
# File 'lib/polars/data_types.rb', line 341

def ordering
  @ordering
end