new: Add GetColumn fn to IBlueRowCollection interface
This allows us to implement python/pandas functionality, much of which is based on column operations.
This commit is contained in:
1 parent
2a4d62a1e9
commit
0d10c2ba5d
24 files changed
+495
-160
No files matched your search
@@ -7,6 +7,8 @@ using bts.collections;
|
||||
|
||||
using Bts.DataStreamCore;
|
||||
|
||||
using mbts.utils;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
using System.Collections.Immutable;
|
||||
@@ -184,7 +186,7 @@ public class DataPacketBuilderTests {
|
||||
}
|
||||
|
||||
static BlueTableImmutable getTable(params (int Id, double Value)[] rows) =>
|
||||
new(schema, ImmutableDictionary.CreateRange(
|
||||
new(schema, ImmutableSortedSet.CreateRange(
|
||||
rows.Select(tup => new KeyValuePair<int, IBlueRow>(tup.Id, getBlueRow(tup)))));
|
||||
|
||||
static MutableBlueRow getBlueRow((int id, double value) tup) =>
|
||||
@@ -203,13 +205,14 @@ public class DataPacketBuilderTests {
|
||||
(int Id, double Value)[]? removedRows = null) {
|
||||
addedRows ??= Array.Empty<(int, double)>();
|
||||
removedRows ??= Array.Empty<(int, double)>();
|
||||
var kvpComp = new ComparerBuilder<KeyValuePair<int, IBlueRow>>() { kv => kv.Key };
|
||||
return new DataPacket(
|
||||
new BlueTableImmutable(schema, ImmutableDictionary.CreateRange(
|
||||
newRows.Select(tup => new KeyValuePair<int, IBlueRow>(tup.Id, getBlueRow(tup))))),
|
||||
new BlueTableImmutable(schema, ImmutableDictionary.CreateRange(
|
||||
addedRows.Select(tup => new KeyValuePair<int, IBlueRow>(tup.Id, getBlueRow(tup))))),
|
||||
new BlueTableImmutable(schema, ImmutableDictionary.CreateRange(
|
||||
removedRows.Select(tup => new KeyValuePair<int, IBlueRow>(tup.Id, getBlueRow(tup))))));
|
||||
new BlueTableImmutable(schema, ImmutableSortedSet.CreateRange(kvpComp, GetRowKvps(newRows))),
|
||||
new BlueTableImmutable(schema, ImmutableSortedSet.CreateRange(kvpComp, GetRowKvps(addedRows))),
|
||||
new BlueTableImmutable(schema, ImmutableSortedSet.CreateRange(kvpComp, GetRowKvps(removedRows))));
|
||||
|
||||
static IEnumerable<KeyValuePair<int, IBlueRow>> GetRowKvps((int Id, double Value)[] rows) =>
|
||||
rows.Select(tup => new KeyValuePair<int, IBlueRow>(tup.Id, getBlueRow(tup)));
|
||||
}
|
||||
|
||||
static (int, double) deconstructRow(IBlueRow row) =>
|
||||
|
||||
Reference in new issue
Block a user