heidi-0.0.0: Tidy data in Haskell

Copyright(c) Marco Zocca (2018-2019)
LicenseBSD-style
Maintainerocramz fripost org
Stabilityexperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell2010

Heidi.Data.Frame.Algorithms.GenericTrie

Contents

Description

 
Synopsis

Row-wise operations

unionColsWith Source #

Arguments

:: (Eq k, TrieKey k) 
=> (v -> v -> v)

Element combination function

-> Frame (Row k v) 
-> Frame (Row k v) 
-> Frame (Row k v) 

Merge two frames by taking the set union of the columns

Filtering

Data tidying

spreadWith Source #

Arguments

:: (TrieKey k, Foldable t, Ord k, Ord v) 
=> (v -> k) 
-> k

"key" key

-> k

"value" key

-> t (Row k v)

input dataframe

-> Frame (Row k v) 

spreadWith moves the unique values of a key column into the column names, spreading the values of a value column across the new columns.

gatherWith Source #

Arguments

:: (Foldable t, Ord k, TrieKey k) 
=> (k -> v) 
-> Set k

set of keys to gather

-> k

"key" key

-> k

"value" key

-> t (Row k v)

input dataframe

-> Frame (Row k v) 

gatherWith moves column names into a "key" column, gathering the column values into a single "value" column

Relational operations

groupBy Source #

Arguments

:: (Foldable t, TrieKey k, Eq k, Ord v) 
=> k

Key to group by

-> t (Row k v)

A 'Frame (GTR.Row k v) can be used here

-> Map v (Frame (Row k v)) 

GROUP BY : given a key and a table that uses it, split the table in multiple tables, one per value taken by the key.

>>> numRows <$> (HM.lookup "129" $ groupBy "id.0" t0)
Just 2

innerJoin Source #

Arguments

:: (Foldable t, Ord v, TrieKey k, Eq v, Eq k) 
=> k

Key into the first table

-> k

Key into the second table

-> t (Row k v)

First dataframe

-> t (Row k v)

Second dataframe

-> Frame (Row k v) 

INNER JOIN : given two dataframes and one key from each, compute the inner join using the keys as relations.

>>> head t0
[("id.0","129"),("qty","1"),("item","book")]
>>> head t1
[("id.1","129"),("price","100")]
>>> head $ innerJoin "id.0" "id.1" t0 t1
[("id.1","129"),("id.0","129"),("qty","5"),("item","book"),("price","100")]

leftOuterJoin :: (Foldable t, Ord v, TrieKey k, Eq v, Eq k) => k -> k -> t (Row k v) -> t (Row k v) -> Frame (Row k v) Source #

LEFT (OUTER) JOIN : given two dataframes and one key from each, compute the left outer join using the keys as relations.