Copyright | (c) Marco Zocca (2018-2019) |
---|---|
License | BSD-style |
Maintainer | ocramz fripost org |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- unionColsWith :: (Eq k, TrieKey k) => (v -> v -> v) -> Frame (Row k v) -> Frame (Row k v) -> Frame (Row k v)
- spreadWith :: (TrieKey k, Foldable t, Ord k, Ord v) => (v -> k) -> k -> k -> t (Row k v) -> Frame (Row k v)
- gatherWith :: (Foldable t, Ord k, TrieKey k) => (k -> v) -> Set k -> k -> k -> t (Row k v) -> Frame (Row k v)
- groupBy :: (Foldable t, TrieKey k, Eq k, Ord v) => k -> t (Row k v) -> Map v (Frame (Row k v))
- innerJoin :: (Foldable t, Ord v, TrieKey k, Eq v, Eq k) => k -> k -> t (Row k v) -> t (Row k v) -> Frame (Row k v)
- 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)
Row-wise operations
:: (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
:: (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.
:: (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
:: (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
:: (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")]