dataframe-core-2.2.0.0: Core data structures for the dataframe library.
Safe HaskellNone
LanguageHaskell2010

DataFrame.Internal.Row

Synopsis

Documentation

data Any where Source #

Constructors

Value :: forall a. Columnable a => a -> Any 
Null :: Any 

Instances

Instances details
Show Any Source # 
Instance details

Defined in DataFrame.Internal.Row

Methods

showsPrec :: Int -> Any -> ShowS #

show :: Any -> String #

showList :: [Any] -> ShowS #

Eq Any Source # 
Instance details

Defined in DataFrame.Internal.Row

Methods

(==) :: Any -> Any -> Bool #

(/=) :: Any -> Any -> Bool #

toAny :: Columnable a => a -> Any Source #

Wraps a value into an Any type. This helps up represent rows as heterogenous lists.

fromAny :: Columnable a => Any -> Maybe a Source #

Unwraps a value from an Any type. A Null cell yields Nothing.

cellAny :: Columnable a => Maybe Bitmap -> Int -> a -> Any Source #

Wrap a column cell into an Any, honouring the column's null bitmap: a slot marked invalid becomes Null, any other slot becomes a Value. Only needs Columnable a (the stored element type), not Columnable (Maybe a).

type Row = Vector Any Source #

(!?) :: [a] -> Int -> Maybe a Source #

mkColumnFromRow :: Int -> [[Any]] -> Column Source #

Reconstruct column i from a list of rows. The element type is taken from the first non-Null cell; a differently-typed cell is skipped. If any cell is Null the result is a nullable column, so a round-trip preserves nulls.

toRowList :: DataFrame -> [[(Text, Any)]] Source #

Convert the whole dataframe to a list of rows, one per row index in natural order; each row lists all columns ordered by column index. Materializes every row, so prefer toRowVector for large frames.

>>> toRowList df
[[("name", "Alice"), ("age", 25), ...], [("name", "Bob"), ("age", 30), ...], ...]

toRowVector :: [Text] -> DataFrame -> Vector Row Source #

Convert the dataframe to a vector of rows containing only the named columns, in the given order. An empty name list yields one empty row per dataframe row.

>>> toRowVector ["name", "age"] df
Vector of rows with only name and age fields

rowValue :: Expr a -> [(Text, Any)] -> Maybe a Source #

Given a row gets the value associated with a field.

Examples

Expand
>>> map (rowValue (F.col @Int "age")) (toRowList df)
[25,30, ...]