You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
df = Daru::DataFrame.new({:name => ['john'], :address => ['NY'], :age => [22]}, :index => [1])
=> #<Daru::DataFrame(1x3)>
name address age
1 john NY 22
df[:id] = 101
=> 101
df
=> #<Daru::DataFrame(1x4)>
name address age id
1 john NY 22 101
So when we add value in a non-existant vector - it essentially creates a new vector and fills the value.
However, the same doesn't work when the existing DF is empty.
df = Daru::DataFrame.new({:name => [], :address => [], :age => []}, :index => [])
=> #<Daru::DataFrame(0x3)>
name address age
df[:id] = 0
NoMethodError: undefined method `to_a' for 0:Fixnum
from /Users/Dipan/.rvm/gems/ruby-2.2.5/gems/daru-0.2.2/lib/daru/dataframe.rb:2629:in `insert_vector_in_empty'
from /Users/Dipan/.rvm/gems/ruby-2.2.5/gems/daru-0.2.2/lib/daru/dataframe.rb:2589:in `insert_or_modify_vector'
from /Users/Dipan/.rvm/gems/ruby-2.2.5/gems/daru-0.2.2/lib/daru/dataframe.rb:2487:in `dispatch_to_axis'
from /Users/Dipan/.rvm/gems/ruby-2.2.5/gems/daru-0.2.2/lib/daru/dataframe.rb:537:in `[]='
from (irb):7
from /Users/Dipan/.rvm/rubies/ruby-2.2.5/bin/irb:11:in `<main>'
A typical expectation would be if the df empty is empty it should just add a vector and return without adding any row. At least don't face an unhandled exception.
Any help?
The text was updated successfully, but these errors were encountered:
Here is the code that works:
So when we add value in a non-existant vector - it essentially creates a new vector and fills the value.
However, the same doesn't work when the existing DF is empty.
A typical expectation would be if the df empty is empty it should just add a vector and return without adding any row. At least don't face an unhandled exception.
Any help?
The text was updated successfully, but these errors were encountered: