namo 0.32.12 → 0.32.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +13 -0
- data/README.md +69 -1
- data/lib/Namo/VERSION.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b3727f5e87d90c759f2423093d4deee86b6179f50cf156828560297f925ff4d0
|
|
4
|
+
data.tar.gz: 8e26c16a0bbe24597732bfd21b2912944b3d684eab00626c3239c2ce25e6d9a4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '08ae91c58efd9cd91084f384c43b0399f6acde45b73e21c53077d91851cf5e20cdef343bd598f4c435f01eec485e1aac5bfe46bf1bb14f390e08a6224ff98f6f'
|
|
7
|
+
data.tar.gz: 2c8f96dbdbc81268789b480a16b1dac618e38f94960959314bf459b7a0bad6eb55d5658f1db490f70153b3686e40f5fe878dfbbd1c60a20cc10d9ea8eddde93a
|
data/CHANGELOG
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
## 20261109
|
|
4
4
|
|
|
5
|
+
0.32.13: ~ README.md: A new section shows a Namo passed to statistics.rb, terminal-table, vega, and Polars-ruby.
|
|
6
|
+
|
|
7
|
+
1. ~ README.md: A section, "Using Namo with other libraries", after "Inspection output", passes a Namo to statistics.rb for statistics, terminal-table for a table, vega for a chart, and Polars-ruby for a pivot.
|
|
8
|
+
2. ~ README.md: The note on summary's reducer: points to statistics.rb.
|
|
9
|
+
3. + comparison/readme_claims.rb: Runs every snippet in "Using Namo with other libraries", in order, then the probe behind its caveat.
|
|
10
|
+
4. ~ comparison/setup: The ruby environment gains statistics.rb 0.11.0, terminal-table 4.0.0, and vega 0.6.0.
|
|
11
|
+
5. ~ comparison/README.md: The new script is described.
|
|
12
|
+
6. ~ comparison/ruby_claims.rb: Polars, Rover, and RedAmber frames are built from a Namo's to_h.
|
|
13
|
+
7. ~ RUBY_COMPARISON.md: Display is left to other libraries, where the others had been said to do it better, and the libraries are said to compose, a Namo's values and to_h being what the three columnar ones are built from.
|
|
14
|
+
8. ~ ROADMAP.md: In "Composition with surrounding systems", Namo leaves tables, charts, statistics, and pivots to other libraries, as 0.24.0 did pivoting.
|
|
15
|
+
9. ~ ROADMAP.md: In 3.x, a Namo switches between row and column storage to suit the operations asked of it. Columnar storage's third step is rewritten, and a "Dynamic layout" section covers which operations suit which layout, a ColumnStore of native buffers, three options for deciding when to switch, how switching interacts with freezing, and what data returns when columns are stored. The second layout kept as a cache and invalidated on mutation is dropped, since the data back door means that not every mutation can be detected.
|
|
16
|
+
10. ~ Namo::VERSION: /0.32.12/0.32.13/
|
|
17
|
+
|
|
5
18
|
0.32.12: + RUBY_COMPARISON.md: Namo is compared with Daru, Rover, Polars-ruby, and RedAmber.
|
|
6
19
|
|
|
7
20
|
1. + RUBY_COMPARISON.md: Namo is compared with Daru 0.3, Rover 1.1.0, Polars-ruby 0.27.1, and RedAmber 0.5.2 on Ruby 4.0.7, feature by feature and in measured timings.
|
data/README.md
CHANGED
|
@@ -1063,6 +1063,74 @@ sales.group_by(:quarter)
|
|
|
1063
1063
|
# ] 4 rows>
|
|
1064
1064
|
```
|
|
1065
1065
|
|
|
1066
|
+
### Using Namo with other libraries
|
|
1067
|
+
|
|
1068
|
+
Namo holds data and computes over it. It leaves tables, charts, statistics, and pivots to libraries made for them. `values`, `to_h`, and `to_a` produce the shapes those libraries take, an Array per column, a Hash of those Arrays, or an Array of Hashes, so passing a Namo to one is usually a single call. Below is one library for each.
|
|
1069
|
+
|
|
1070
|
+
Statistics, with statistics.rb, whose opt-in patch gives every Enumerable `mean`, `median`, `standard_deviation`, and more:
|
|
1071
|
+
|
|
1072
|
+
```ruby
|
|
1073
|
+
require 'statistics-enumerable'
|
|
1074
|
+
|
|
1075
|
+
sales.values(:revenue).mean # => 1250.0
|
|
1076
|
+
sales.values(:revenue).standard_deviation # => 250.0
|
|
1077
|
+
|
|
1078
|
+
sales[:revenue_z] = proc{|row, namo| (row[:revenue] - namo.values(:revenue).mean) / namo.values(:revenue).standard_deviation}
|
|
1079
|
+
sales.values(:revenue_z) # => [-1.0, 1.0, -1.0, 1.0]
|
|
1080
|
+
|
|
1081
|
+
sales.group_by(:product).summary(:revenue, reducer: :mean).to_a
|
|
1082
|
+
# => [{member: "Widget", revenue: 1250.0}, {member: "Gadget", revenue: 1250.0}]
|
|
1083
|
+
```
|
|
1084
|
+
|
|
1085
|
+
Since Namo is Enumerable, the patch applies to it too, but a Namo iterates over Rows, so `sales.mean` raises an error. Call these methods on a column instead.
|
|
1086
|
+
|
|
1087
|
+
A table in the terminal, with terminal-table:
|
|
1088
|
+
|
|
1089
|
+
```ruby
|
|
1090
|
+
require 'terminal-table'
|
|
1091
|
+
|
|
1092
|
+
columns = sales.values(:product, :quarter, :revenue)
|
|
1093
|
+
puts Terminal::Table.new(headings: columns.keys, rows: columns.values.transpose)
|
|
1094
|
+
# +---------+---------+---------+
|
|
1095
|
+
# | product | quarter | revenue |
|
|
1096
|
+
# +---------+---------+---------+
|
|
1097
|
+
# | Widget | Q1 | 1000.0 |
|
|
1098
|
+
# | Widget | Q2 | 1500.0 |
|
|
1099
|
+
# | Gadget | Q1 | 1000.0 |
|
|
1100
|
+
# | Gadget | Q2 | 1500.0 |
|
|
1101
|
+
# +---------+---------+---------+
|
|
1102
|
+
```
|
|
1103
|
+
|
|
1104
|
+
A chart, with vega, which renders in IRuby or on a web page. Vega-Lite takes the rows as they are:
|
|
1105
|
+
|
|
1106
|
+
```ruby
|
|
1107
|
+
require 'vega'
|
|
1108
|
+
|
|
1109
|
+
Vega.lite
|
|
1110
|
+
.data(sales.to_a)
|
|
1111
|
+
.mark(type: 'bar')
|
|
1112
|
+
.encoding(x: {field: 'quarter'}, y: {field: 'revenue', type: 'quantitative'}, color: {field: 'product'})
|
|
1113
|
+
```
|
|
1114
|
+
|
|
1115
|
+
A pivot, with Polars, since Namo does not pivot. Polars takes the columnar form:
|
|
1116
|
+
|
|
1117
|
+
```ruby
|
|
1118
|
+
require 'polars-df'
|
|
1119
|
+
|
|
1120
|
+
Polars::DataFrame.new(sales.values(:product, :quarter, :revenue)).pivot('quarter', index: 'product', values: 'revenue')
|
|
1121
|
+
# shape: (2, 3)
|
|
1122
|
+
# ┌─────────┬────────┬────────┐
|
|
1123
|
+
# │ product ┆ Q1 ┆ Q2 │
|
|
1124
|
+
# │ --- ┆ --- ┆ --- │
|
|
1125
|
+
# │ str ┆ f64 ┆ f64 │
|
|
1126
|
+
# ╞═════════╪════════╪════════╡
|
|
1127
|
+
# │ Widget ┆ 1000.0 ┆ 1500.0 │
|
|
1128
|
+
# │ Gadget ┆ 1000.0 ┆ 1500.0 │
|
|
1129
|
+
# └─────────┴────────┴────────┘
|
|
1130
|
+
```
|
|
1131
|
+
|
|
1132
|
+
These examples use `values` with several dimensions rather than a projection, because a projection also carries every formula it does not name, still live, so `:revenue_z` would be included too. `comparison/readme_claims.rb` runs these examples.
|
|
1133
|
+
|
|
1066
1134
|
### Named Namos
|
|
1067
1135
|
|
|
1068
1136
|
A Namo can carry a name, passed by the `name:` keyword and read or set through the `name` accessor:
|
|
@@ -1180,7 +1248,7 @@ gt.as_summary(:weight) # gt's data becomes the summary; retu
|
|
|
1180
1248
|
gt.as_detail(:assembly) # gt's data becomes the detail; returns gt
|
|
1181
1249
|
```
|
|
1182
1250
|
|
|
1183
|
-
`reducer:` is any method the member's column responds to — `:sum` (the default) and `:mean` are typical (`:mean` via a statistics gem that adds `Array#mean
|
|
1251
|
+
`reducer:` is any method the member's column responds to — `:sum` (the default) and `:mean` are typical (`:mean` via a statistics gem that adds `Array#mean`, as statistics.rb does: see [Using Namo with other libraries](#using-namo-with-other-libraries)).
|
|
1184
1252
|
|
|
1185
1253
|
#### A block for per-member reductions
|
|
1186
1254
|
|
data/lib/Namo/VERSION.rb
CHANGED