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.



352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
# File 'lib/polars/data_types.rb', line 352

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.



350
351
352
# File 'lib/polars/data_types.rb', line 350

def categories
  @categories
end

#orderingObject (readonly)

Returns the value of attribute ordering.



350
351
352
# File 'lib/polars/data_types.rb', line 350

def ordering
  @ordering
end