Module: Eps::Utils
- Defined in:
- lib/eps/utils.rb
Class Method Summary collapse
Class Method Details
.column_type(c, k) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/eps/utils.rb', line 3 def self.column_type(c, k) if !c raise ArgumentError, "Missing column: #{k}" elsif c.all?(&:nil?) # goes here for empty as well nil elsif c.any?(&:nil?) raise ArgumentError, "Missing values in column #{k}" elsif c.all?(Numeric) "numeric" elsif c.all?(String) "categorical" elsif c.all? { |v| v == true || v == false } "categorical" # boolean else raise ArgumentError, "Column values must be all numeric, all string, or all boolean: #{k}" end end |