Skip to content

Commit 2b38c0f

Browse files
committed
added notebook and bugfix
1 parent 9137dab commit 2b38c0f

File tree

6 files changed

+948
-128
lines changed

6 files changed

+948
-128
lines changed

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ Written in pure Ruby so should work with all ruby implementations.
2929

3030
## Notebooks
3131

32-
* [Analysis and plotting of a data set comprising of music listening habits of a last.fm user(iruby notebook)](http://nbviewer.ipython.org/github/v0dro/daru/blob/master/notebooks/intro_with_music_data_.ipynb)
32+
* [Analysis and plotting of a data set comprising of music listening habits of a last.fm user](http://nbviewer.ipython.org/github/v0dro/daru/blob/master/notebooks/intro_with_music_data_.ipynb)
3333

3434
## Blog Posts
3535

3636
* [Data Analysis in RUby: Basic data manipulation and plotting](http://v0dro.github.io/blog/2014/11/25/data-analysis-in-ruby-basic-data-manipulation-and-plotting/)
37+
* [Data Analysis in RUby: Splitting, sorting, aggregating data and data types]()
3738

3839
## Documentation
3940

@@ -275,8 +276,6 @@ Keep/remove row according to a specified condition:
275276
```
276277
The same can be applied to vectors using `filter_vectors`.
277278

278-
To iterate over a DataFrame and perform operations on rows or vectors, use `#each_row` or `#each_vector`.
279-
280279
To change the values of a row/vector while iterating through the DataFrame, use `map_rows` or `map_vectors`:
281280

282281
```ruby
@@ -298,8 +297,6 @@ To change the values of a row/vector while iterating through the DataFrame, use
298297

299298
```
300299

301-
Rows/vectors can be deleted using `delete_row` or `delete_vector`.
302-
303300
#### Basic Maths Operations
304301

305302
Performing a binary arithmetic operation on two `Daru::Vector` objects will return a `Vector` object in which the operation will be performed on elements of the same index.
@@ -321,6 +318,10 @@ Performing a binary arithmetic operation on two `Daru::Vector` objects will retu
321318

322319
Arithmetic operators applied on a single Numeric will perform the operation with that number against the entire vector.
323320

321+
#### Splitting and aggregation of data
322+
323+
`Daru::DataFrame` provides the `#group_by` method to split or aggregate data. Its very similar to SQL GROUP BY. Check the [blog post]() for details.
324+
324325
#### Statistics Operations
325326

326327
Daru::Vector has a whole lot of statistics operations to maintain compatibility with Statsample::Vector. Check the docs for details.
@@ -354,7 +355,6 @@ Head over to the tutorials and notebooks listed above for more examples.
354355
* Create a new vector in map_rows if any of the already present rows dont match the one assigned in the block.
355356
* Sort by index.
356357
* Statistics on DataFrame over rows and columns.
357-
* Produce multiple summary statistics in one shot.
358358
* Cumulative sum.
359359
* Time series support.
360360
* Calculate percentage change.

lib/daru/core/group_by.rb

+6-3
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,18 @@ def all_indices_for arry, element
161161
end
162162

163163
def symbolize arry
164+
symbolized_arry =
164165
if arry.all? { |e| e.is_a?(Array) }
165-
arry.map! do |sub_arry|
166-
sub_arry.map! do |e|
166+
arry.map do |sub_arry|
167+
sub_arry.map do |e|
167168
e.is_a?(Numeric) ? e : e.to_sym
168169
end
169170
end
170171
else
171-
arry.map! { |e| e.is_a?(Numeric) ? e : e.to_sym }
172+
arry.map { |e| e.is_a?(Numeric) ? e : e.to_sym }
172173
end
174+
175+
symbolized_arry
173176
end
174177

175178
def multi_indexed_grouping?

notebooks/.ipynb_checkpoints/intro_with_music_data_-checkpoint.ipynb

+302
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)