This library adds a DynamicObject called that can be used as row key of Deedle frames and series.
The functions in this library all either create frames with objects or work with frames or series that have objects.
The modules allow for easy creation of filters und processing of either series or frames.
This library is available as nuget package(from nuget):
Add the NuGet package as reference and open Drafo/Drafo.Core and any module you want to use.
Because Drafo is build on Deedle it is highly recommended to use Deedle too.
You can create your own frame, with objects as row keys, transform existing frames into frames that have objects
or read in csv files and then transform them.
Then one can use the functions in the Drafo core or the modules to manipulate series or frames that have objects as row keys.
We have a frame of floats that we want to use some operations of the Drafo library on. So first we must index it,
for that we add columns that should be turned into , should the frame not contain such columns jet.
let exampleFrame =
frame [
("Column1")=>series ["row1"=>2.;"row2"=>4.5;"row3"=>3.7;"row4"=>2.9]
("Column2")=>series ["row1"=>4.;"row2"=>5.5;"row3"=>6.9;"row4"=>5.]
]
let exampleFrameWithKeyCols =
exampleFrame
|>Frame.addCol "Gen"(series ["row1"=>"A";"row2"=>"A";"row3"=>"A";"row4"=>"A"])
|>Frame.addCol "TecRep"(series ["row1"=>"B";"row2"=>"B";"row3"=>"C";"row4"=>"C"])
|>Frame.addCol "BioRep"(series ["row1"=>"D";"row2"=>"E";"row3"=>"D";"row4"=>"E"])
let indexedFrameWithKeyCols = indexWithColumnValues ["Gen";"TecRep";"BioRep"] exampleFrameWithKeyCols
indexedFrameWithKeyCols.Print()
Column1 Column2 Gen TecRep BioRep
Gen: A
TecRep: B
BioRep: D
-> 2 4 A B D
Gen: A
TecRep: B
BioRep: E
-> 4.5 5.5 A B E
Gen: A
TecRep: C
BioRep: D
-> 3.7 6.9 A C D
Gen: A
TecRep: C
BioRep: E
-> 2.9 5 A C E
|
as you can see, we have now a multi-tiered for each row that is unique. From this point, one can go in several directions.
For example, one could subtract or add to all values in a series (Column) with the transform
function or one could create
filters with the modules GroupFilter
or NumericFilter
or the filter
function. Here we want to aggregate a single column.
let singleColumnAggregateMean = numAggregat Mean indexedFrameWithKeyCols "Column1" ["Gen";"TecRep"] (seq [])
singleColumnAggregateMean.Print()
Gen: A
TecRep: B
-> 3.25
Gen: A
TecRep: C
-> 3.3
|
namespace Deedle
Multiple items
namespace FSharp
--------------------
namespace Microsoft.FSharp
namespace FSharp.Stats
namespace FSharpAux
namespace Drafo
module Core
from Drafo
namespace NumericAggregation
module NumericAggregation
from NumericAggregation
val exampleFrame: Frame<string,string>
val frame: columns: seq<'a * #ISeries<'c>> -> Frame<'c,'a> (requires equality and equality)
val series: observations: seq<'a * 'b> -> Series<'a,'b> (requires equality)
val exampleFrameWithKeyCols: Frame<string,string>
Multiple items
module Frame
from Deedle
--------------------
type Frame =
static member ReadCsv: location: string * hasHeaders: Nullable<bool> * inferTypes: Nullable<bool> * inferRows: Nullable<int> * schema: string * separators: string * culture: string * maxRows: Nullable<int> * missingValues: string[] * preferOptions: bool -> Frame<int,string> + 1 overload
static member ReadReader: reader: IDataReader -> Frame<int,string>
static member CustomExpanders: Dictionary<Type,Func<obj,seq<string * Type * obj>>>
static member NonExpandableInterfaces: ResizeArray<Type>
static member NonExpandableTypes: HashSet<Type>
--------------------
type Frame<'TRowKey,'TColumnKey (requires equality and equality)> =
interface IDynamicMetaObjectProvider
interface INotifyCollectionChanged
interface IFsiFormattable
interface IFrame
new: rowIndex: IIndex<'TRowKey> * columnIndex: IIndex<'TColumnKey> * data: IVector<IVector> * indexBuilder: IIndexBuilder * vectorBuilder: IVectorBuilder -> Frame<'TRowKey,'TColumnKey> + 1 overload
member AddColumn: column: 'TColumnKey * series: seq<'V> -> unit + 3 overloads
member AggregateRowsBy: groupBy: seq<'TColumnKey> * aggBy: seq<'TColumnKey> * aggFunc: Func<Series<'TRowKey,'a>,'b> -> Frame<int,'TColumnKey>
member Clone: unit -> Frame<'TRowKey,'TColumnKey>
member ColumnApply: f: Func<Series<'TRowKey,'T>,ISeries<'TRowKey>> -> Frame<'TRowKey,'TColumnKey> + 1 overload
member DropColumn: column: 'TColumnKey -> unit
...
--------------------
new: names: seq<'TColumnKey> * columns: seq<ISeries<'TRowKey>> -> Frame<'TRowKey,'TColumnKey>
new: rowIndex: Indices.IIndex<'TRowKey> * columnIndex: Indices.IIndex<'TColumnKey> * data: IVector<IVector> * indexBuilder: Indices.IIndexBuilder * vectorBuilder: Vectors.IVectorBuilder -> Frame<'TRowKey,'TColumnKey>
val addCol: column: 'C -> series: Series<'R,'V> -> frame: Frame<'R,'C> -> Frame<'R,'C> (requires equality and equality)
val indexedFrameWithKeyCols: Frame<Key,string>
val indexWithColumnValues: keyCols: seq<string> -> f: Frame<'a,string> -> Frame<Key,string> (requires equality)
static member FrameExtensions.Print: frame: Frame<'K,'V> -> unit (requires equality and equality)
static member FrameExtensions.Print: frame: Frame<'K,'V> * printTypes: bool -> unit (requires equality and equality)
val singleColumnAggregateMean: Series<Key,float>
val numAggregat: aggregation: NumericAggregation -> fp: Frame<Key,string> -> col: string -> keyC: seq<string> -> filterCols: seq<Series<Key,bool>> -> Series<Key,float>
union case NumericAggregation.Mean: NumericAggregation
Multiple items
val seq: sequence: seq<'T> -> seq<'T>
<summary>Builds a sequence using sequence expression syntax</summary>
<param name="sequence">The input sequence.</param>
<returns>The result sequence.</returns>
<example id="seq-cast-example"><code lang="fsharp">
seq { for i in 0..10 do yield (i, i*i) }
</code></example>
--------------------
type seq<'T> = System.Collections.Generic.IEnumerable<'T>
<summary>An abbreviation for the CLI type <see cref="T:System.Collections.Generic.IEnumerable`1" /></summary>
<remarks>
See the <see cref="T:Microsoft.FSharp.Collections.SeqModule" /> module for further operations related to sequences.
See also <a href="https://docs.microsoft.com/dotnet/fsharp/language-reference/sequences">F# Language Guide - Sequences</a>.
</remarks>
static member SeriesExtensions.Print: series: Series<'K,'V> -> unit (requires equality)