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.



362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
# File 'lib/polars/data_types.rb', line 362

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.



360
361
362
# File 'lib/polars/data_types.rb', line 360

def categories
  @categories
end

#orderingObject (readonly)

Returns the value of attribute ordering.



360
361
362
# File 'lib/polars/data_types.rb', line 360

def ordering
  @ordering
end