davidrichards-data_frame 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/data_frame.rb +3 -1
- data/spec/data_frame_spec.rb +11 -0
- metadata +2 -2
data/VERSION.yml
CHANGED
data/lib/data_frame.rb
CHANGED
@@ -120,6 +120,8 @@ class DataFrame
|
|
120
120
|
cont
|
121
121
|
end
|
122
122
|
end
|
123
|
+
alias :to_hash :columns
|
124
|
+
alias :to_dictionary :columns
|
123
125
|
|
124
126
|
def render_row(sym)
|
125
127
|
i = self.row_labels.index(sym)
|
@@ -148,5 +150,5 @@ class DataFrame
|
|
148
150
|
self.labels.delete_at(i)
|
149
151
|
true
|
150
152
|
end
|
151
|
-
|
153
|
+
|
152
154
|
end
|
data/spec/data_frame_spec.rb
CHANGED
@@ -115,4 +115,15 @@ describe DataFrame do
|
|
115
115
|
@df.add [5, 6, 7, 8]
|
116
116
|
@df.rows.should eql(@df.items)
|
117
117
|
end
|
118
|
+
|
119
|
+
it "should be able to export a hash" do
|
120
|
+
@df.add [1,2,3,4]
|
121
|
+
@df.add [5, 6, 7, 8]
|
122
|
+
hash = @df.to_hash
|
123
|
+
values = [[1,5],[2,6],[3,7],[4,8]]
|
124
|
+
hash.keys.size.should eql(@labels.size)
|
125
|
+
hash.keys.all? {|e| @labels.should be_include(e)}
|
126
|
+
hash.values.size.should eql(@labels.size)
|
127
|
+
hash.values.all? {|e| values.should be_include(e)}
|
128
|
+
end
|
118
129
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: davidrichards-data_frame
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Richards
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-11 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|