def one_to_many(parent_fields, pattern)
      vars, numbers = one_to_many_components(pattern)

      DataFrame.new([], order: [*parent_fields, '_col_id', *vars]).tap do |ds|
        each_row do |row|
          verbatim = parent_fields.map { |f| [f, row[f]] }.to_h
          numbers.each do |n|
            generated = one_to_many_row row, n, vars, pattern
            next if generated.values.all?(&:nil?)

            ds.add_row(verbatim.merge(generated).merge('_col_id' => n))
          end
        end
        ds.update
      end
    end
Creates a new dataset for one to many relations
on a dataset, based on pattern of field names.

for example, you have a survey for number of children
with this structure:
id, name, child_name_1, child_age_1, child_name_2, child_age_2
with
ds.one_to_many([:id], "child_%v_%n"
the field of first parameters will be copied verbatim
to new dataset, and fields which responds to second
pattern will be added one case for each different %n.

@example
cases=[
['1','george','red',10,'blue',20,nil,nil],
['2','fred','green',15,'orange',30,'white',20],
['3','alfred',nil,nil,nil,nil,nil,nil]
]
ds=Daru::DataFrame.rows(cases, order:
[:id, :name,
:car_color1, :car_value1,
:car_color2, :car_value2,
:car_color3, :car_value3])
ds.one_to_many([:id],'car_%v%n').to_matrix
#=> Matrix[
#   ["red", "1", 10],
#   ["blue", "1", 20],
#   ["green", "2", 15],
#   ["orange", "2", 30],
#   ["white", "2", 20]
#   ]