Module: DaruLite::DataFrame::Missable
- Extended by:
- Gem::Deprecate
- Included in:
- DaruLite::DataFrame
- Defined in:
- lib/daru_lite/data_frame/missable.rb
Instance Method Summary collapse
- #has_missing_data? ⇒ Boolean (also: #flawed?)
-
#missing_values_rows(missing_values = [nil]) ⇒ Object
(also: #vector_missing_values)
Return a vector with the number of missing values in each row.
- #rolling_fillna(direction = :forward) ⇒ Object
-
#rolling_fillna!(direction = :forward) ⇒ Object
Rolling fillna replace all Float::NAN and NIL values with the preceeding or following value.
Instance Method Details
#has_missing_data? ⇒ Boolean Also known as: flawed?
67 68 69 |
# File 'lib/daru_lite/data_frame/missable.rb', line 67 def has_missing_data? @data.any? { |vec| vec.include_values?(*DaruLite::MISSING_VALUES) } end |
#missing_values_rows(missing_values = [nil]) ⇒ Object Also known as: vector_missing_values
Return a vector with the number of missing values in each row.
Arguments
-
missing_values- An Array of the values that should be
treated as ‘missing’. The default missing value is nil.
56 57 58 59 60 61 62 |
# File 'lib/daru_lite/data_frame/missable.rb', line 56 def missing_values_rows(missing_values = [nil]) number_of_missing = each_row.map do |row| row.indexes(*missing_values).size end DaruLite::Vector.new number_of_missing, index: @index, name: "#{@name}_missing_rows" end |
#rolling_fillna(direction = :forward) ⇒ Object
46 47 48 |
# File 'lib/daru_lite/data_frame/missable.rb', line 46 def rolling_fillna(direction = :forward) dup.rolling_fillna!(direction) end |
#rolling_fillna!(direction = :forward) ⇒ Object
Rolling fillna replace all Float::NAN and NIL values with the preceeding or following value
41 42 43 44 |
# File 'lib/daru_lite/data_frame/missable.rb', line 41 def rolling_fillna!(direction = :forward) @data.each { |vec| vec.rolling_fillna!(direction) } self end |