Skip to content

Commit

Permalink
update gemspec and minor doc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
v0dro committed Aug 19, 2015
1 parent 2a05cd9 commit e511844
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 20 deletions.
30 changes: 26 additions & 4 deletions daru.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ require 'daru/version.rb'

Daru::DESCRIPTION = <<MSG
Daru (Data Analysis in RUby) is a library for analysis, manipulation and visualization
of data.
of data. Daru works seamlessly accross interpreters and leverages interpreter-specific
optimizations whenever they are available.
Daru works with Ruby arrays and NMatrix, thus working seamlessly accross
ruby interpreters, at the same time providing speed for those who need it, while
making working with data super simple and intuitive.
It is the default data storage gem for all the statsample gems (glm, timeseries, etc.)
and can be used with many others like mixed_models, gnuplotrb, nyaplot and iruby.
MSG

Gem::Specification.new do |spec|
Expand All @@ -27,6 +27,28 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

spec.post_install_message = <<-EOF
*************************************************************************
Thank you for installing daru!
oOOOOOo
,| oO
//| |
\\| |
`| |
`-----`
Hope you love daru! For enhanced interactivity and better visualizations,
consider using gnuplotrb and nyaplot with iruby. For statistics use the
statsample family.
Read the README for interesting use cases and examples.
Cheers!
*************************************************************************
EOF

spec.add_runtime_dependency 'reportbuilder', '~> 1.4'
spec.add_runtime_dependency 'spreadsheet', '~> 1.0.3'

Expand Down
30 changes: 14 additions & 16 deletions lib/daru/dataframe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1587,22 +1587,21 @@ def join(other_df,opts={})
# to new dataset, and fields which responds to second
# pattern will be added one case for each different %n.
#
# == Usage
# @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]
# ]
#
# #=> Matrix[
# # ["red", "1", 10],
# # ["blue", "1", 20],
# # ["green", "2", 15],
# # ["orange", "2", 30],
# # ["white", "2", 20]
# # ]
def one_to_many(parent_fields, pattern)
re = Regexp.new pattern.gsub("%v","(.+?)").gsub("%n","(\\d+?)")
ds_vars = parent_fields.dup
Expand Down Expand Up @@ -1670,14 +1669,14 @@ def add_vectors_by_split_recode(name_, join='-', sep=Daru::SPLIT_TOKEN)
# * table - String specifying name of the table that will created in SQL.
# * charset - Character set. Default is "UTF8".
#
# == Usage
# @example
#
# ds = Daru::DataFrame.new({
# :id => Daru::Vector.new([1,2,3,4,5]),
# :name => Daru::Vector.new(%w{Alex Peter Susan Mary John})
# })
# ds.create_sql('names')
# ==>"CREATE TABLE names (id INTEGER,\n name VARCHAR (255)) CHARACTER SET=UTF8;"
# #=>"CREATE TABLE names (id INTEGER,\n name VARCHAR (255)) CHARACTER SET=UTF8;"
#
def create_sql(table,charset="UTF8")
sql = "CREATE TABLE #{table} ("
Expand Down Expand Up @@ -1740,6 +1739,8 @@ def to_a
arry
end

# Convert to json. If no_index is false then the index will NOT be included
# in the JSON thus created.
def to_json no_index=true
if no_index
self.to_a[0].to_json
Expand Down Expand Up @@ -1814,12 +1815,9 @@ def update
@data.each { |v| v.update } if Daru.lazy_update
end

# Rename the DataFrame.
def rename new_name
if new_name.is_a?(Numeric)
@name = new_name
return
end
@name = new_name.to_sym
@name = new_name
end

# Write this DataFrame to a CSV file.
Expand Down

0 comments on commit e511844

Please sign in to comment.