system tells 'key': undefined method '[]' for nil:NilClass (NoMethodError)
I have found the reason. DateTimeIndex's constructor doesn't call super.
I add follow code then everything is OK.
class Daru::DateTimeIndex
def initialize data, opts={freq: nil}
super data
Helper.possibly_convert_to_date_time data
@offset =
case opts[:freq]
when :infer then Helper.infer_offset(data)
when nil then nil
else Helper.offset_from_frequency(opts[:freq])
end
@frequency = @offset ? @offset.freq_string : nil
@data = data.each_with_index.to_a.sort_by(&:first)
@periods = data.size
end
end
For examle, this code can't work
system tells
'key': undefined method '[]' for nil:NilClass (NoMethodError)
I have found the reason. DateTimeIndex's constructor doesn't call super.
I add follow code then everything is OK.