require 'daru'
Install the spreadsheet gem version ~>1.1.1 for using spreadsheet functions. Install the mechanize gem version ~>2.7.5 for using mechanize functions.
true
df = Daru::DataFrame.new({b: [11,12,13,14,15], a: [1,2,3,4,5],
c: [11,22,33,44,55]},
order: [:a, :b, :c],
index: [:one, :two, :three, :four, :five])
a | b | c | |
---|---|---|---|
one | 1 | 11 | 11 |
two | 2 | 12 | 22 |
three | 3 | 13 | 33 |
four | 4 | 14 | 44 |
five | 5 | 15 | 55 |
df.to_html
"<b> Daru::DataFrame(5x3) </b>\n<table>\n <thead>\n \n <tr>\n <th></th>\n \n <th>a</th>\n \n <th>b</th>\n \n <th>c</th>\n \n </tr>\n \n</thead>\n <tbody>\n \n <tr>\n <td>one</td>\n \n <td>1</td>\n \n <td>11</td>\n \n <td>11</td>\n \n </tr>\n \n <tr>\n <td>two</td>\n \n <td>2</td>\n \n <td>12</td>\n \n <td>22</td>\n \n </tr>\n \n <tr>\n <td>three</td>\n \n <td>3</td>\n \n <td>13</td>\n \n <td>33</td>\n \n </tr>\n \n <tr>\n <td>four</td>\n \n <td>4</td>\n \n <td>14</td>\n \n <td>44</td>\n \n </tr>\n \n <tr>\n <td>five</td>\n \n <td>5</td>\n \n <td>15</td>\n \n <td>55</td>\n \n </tr>\n \n\n \n</tbody>\n</table>"
a = Daru::Vector.new([1,2,3,4,5])
0 | 1 |
1 | 2 |
2 | 3 |
3 | 4 |
4 | 5 |
a.to_html
"<b> Daru::Vector(5) </b>\n<table>\n \n \n <tr>\n <td>0</td>\n <td>1</td>\n </tr>\n\n <tr>\n <td>1</td>\n <td>2</td>\n </tr>\n\n <tr>\n <td>2</td>\n <td>3</td>\n </tr>\n\n <tr>\n <td>3</td>\n <td>4</td>\n </tr>\n\n <tr>\n <td>4</td>\n <td>5</td>\n </tr>\n\n\n\n</table>"
a.to_html_thead
""
a.to_html_tbody
"\n <tr>\n <td>0</td>\n <td>1</td>\n </tr>\n\n <tr>\n <td>1</td>\n <td>2</td>\n </tr>\n\n <tr>\n <td>2</td>\n <td>3</td>\n </tr>\n\n <tr>\n <td>3</td>\n <td>4</td>\n </tr>\n\n <tr>\n <td>4</td>\n <td>5</td>\n </tr>\n\n\n"
tuples = [
[:a, :one, :foo],
[:a, :two, :bar],
[:b, :one, :bar],
[:b, :two, :baz]
]
multi_index = Daru::MultiIndex.from_tuples(tuples)
Daru::MultiIndex(4x3) | ||
---|---|---|
a | one | foo |
two | bar | |
b | one | bar |
two | baz |
vec_mi = Daru::Vector.new [1,2,3,4], name: :mi, index: multi_index
mi | |||
---|---|---|---|
a | one | foo | 1 |
two | bar | 2 | |
b | one | bar | 3 |
two | baz | 4 |
vec_mi.to_html
"<b> Daru::Vector(4) </b>\n<table>\n \n <tr>\n <th colspan=\"3\"> </th>\n <th>mi</th>\n </tr>\n\n \n <tr>\n \n <th rowspan=\"2\">a</th>\n \n <th rowspan=\"1\">one</th>\n \n <th rowspan=\"1\">foo</th>\n \n <td>1</td>\n </tr>\n\n <tr>\n \n <th rowspan=\"1\">two</th>\n \n <th rowspan=\"1\">bar</th>\n \n <td>2</td>\n </tr>\n\n <tr>\n \n <th rowspan=\"2\">b</th>\n \n <th rowspan=\"1\">one</th>\n \n <th rowspan=\"1\">bar</th>\n \n <td>3</td>\n </tr>\n\n <tr>\n \n <th rowspan=\"1\">two</th>\n \n <th rowspan=\"1\">baz</th>\n \n <td>4</td>\n </tr>\n\n\n\n</table>"
vec_mi.to_html_tbody
"\n <tr>\n \n <th rowspan=\"2\">a</th>\n \n <th rowspan=\"1\">one</th>\n \n <th rowspan=\"1\">foo</th>\n \n <td>1</td>\n </tr>\n\n <tr>\n \n <th rowspan=\"1\">two</th>\n \n <th rowspan=\"1\">bar</th>\n \n <td>2</td>\n </tr>\n\n <tr>\n \n <th rowspan=\"2\">b</th>\n \n <th rowspan=\"1\">one</th>\n \n <th rowspan=\"1\">bar</th>\n \n <td>3</td>\n </tr>\n\n <tr>\n \n <th rowspan=\"1\">two</th>\n \n <th rowspan=\"1\">baz</th>\n \n <td>4</td>\n </tr>\n\n\n"
vec_mi.to_html_thead
"\n <tr>\n <th colspan=\"3\"> </th>\n <th>mi</th>\n </tr>\n"