@@ -1587,22 +1587,21 @@ def join(other_df,opts={})
15871587 # to new dataset, and fields which responds to second
15881588 # pattern will be added one case for each different %n.
15891589 #
1590- # == Usage
1590+ # @example
15911591 # cases=[
15921592 # ['1','george','red',10,'blue',20,nil,nil],
15931593 # ['2','fred','green',15,'orange',30,'white',20],
15941594 # ['3','alfred',nil,nil,nil,nil,nil,nil]
15951595 # ]
15961596 # ds=Daru::DataFrame.rows(cases, order: [:id, :name, :car_color1, :car_value1, :car_color2, :car_value2, :car_color3, :car_value3])
15971597 # ds.one_to_many([:id],'car_%v%n').to_matrix
1598- # => Matrix[
1599- # ["red", "1", 10],
1600- # ["blue", "1", 20],
1601- # ["green", "2", 15],
1602- # ["orange", "2", 30],
1603- # ["white", "2", 20]
1604- # ]
1605- #
1598+ # #=> Matrix[
1599+ # # ["red", "1", 10],
1600+ # # ["blue", "1", 20],
1601+ # # ["green", "2", 15],
1602+ # # ["orange", "2", 30],
1603+ # # ["white", "2", 20]
1604+ # # ]
16061605 def one_to_many ( parent_fields , pattern )
16071606 re = Regexp . new pattern . gsub ( "%v" , "(.+?)" ) . gsub ( "%n" , "(\\ d+?)" )
16081607 ds_vars = parent_fields . dup
@@ -1670,14 +1669,14 @@ def add_vectors_by_split_recode(name_, join='-', sep=Daru::SPLIT_TOKEN)
16701669 # * table - String specifying name of the table that will created in SQL.
16711670 # * charset - Character set. Default is "UTF8".
16721671 #
1673- # == Usage
1672+ # @example
16741673 #
16751674 # ds = Daru::DataFrame.new({
16761675 # :id => Daru::Vector.new([1,2,3,4,5]),
16771676 # :name => Daru::Vector.new(%w{Alex Peter Susan Mary John})
16781677 # })
16791678 # ds.create_sql('names')
1680- # = =>"CREATE TABLE names (id INTEGER,\n name VARCHAR (255)) CHARACTER SET=UTF8;"
1679+ # # =>"CREATE TABLE names (id INTEGER,\n name VARCHAR (255)) CHARACTER SET=UTF8;"
16811680 #
16821681 def create_sql ( table , charset = "UTF8" )
16831682 sql = "CREATE TABLE #{ table } ("
@@ -1740,6 +1739,8 @@ def to_a
17401739 arry
17411740 end
17421741
1742+ # Convert to json. If no_index is false then the index will NOT be included
1743+ # in the JSON thus created.
17431744 def to_json no_index = true
17441745 if no_index
17451746 self . to_a [ 0 ] . to_json
@@ -1814,12 +1815,9 @@ def update
18141815 @data . each { |v | v . update } if Daru . lazy_update
18151816 end
18161817
1818+ # Rename the DataFrame.
18171819 def rename new_name
1818- if new_name . is_a? ( Numeric )
1819- @name = new_name
1820- return
1821- end
1822- @name = new_name . to_sym
1820+ @name = new_name
18231821 end
18241822
18251823 # Write this DataFrame to a CSV file.
0 commit comments