SciRuby / daru

Data Analysis in RUby
BSD 2-Clause "Simplified" License
1.04k stars 139 forks source link

Partial solution to Issue #308 #326

Closed gusandrianos closed 7 years ago

gusandrianos commented 7 years ago

This is partially solving #308 I wasn't able to test the functionality using the method from_csv_hash_with_headers because it wouldn't change the original values it was given, but only the local ones. So trying to increment the number I was testing by one, was impossible for the original value.

I found that I needed to pass the &block argument to from_csv and it's children to pass blocks correctly as it did not work otherwise.

I passed a very simple block, the file contains two lines and four fields, I am unsure if that's enough because it doesn't check many cases, it just checks if the functionality is there, and it's up to the user to go crazy with it.

This is my first contribution ever, I'd love to hear your thoughts.

zverok commented 7 years ago

I believe, that solving the issue "there are no test for <featurename>" includes some analysis for "how <featurename> should be used".

For all I can understand from discussion in https://github.com/SciRuby/daru/issues/308, expected usage of block passing to from_csv is "additional processing for each row".

So, "intuitive" example would be something like this:

df = Daru::DataFrame.from_csv('path/to/some.csv') { |row| 
 [row[0].to_i, row[1] || 'Default', Date.parse(row[2]) .... 
}

...which probably means you should not only write tests but adjust functionality itself.

gusandrianos commented 7 years ago

@zverok You're right that's how it should work.

v0dro commented 7 years ago

Closed due to no further progress.