dataframe-operations-2.4.0.0: Column operations, expression DSL, and statistics for the dataframe ecosystem.
Safe HaskellNone
LanguageHaskell2010

DataFrame.Functions

Synopsis

Documentation

max :: (Columnable a, Ord a) => Expr a -> Expr a -> Expr a Source #

min :: (Columnable a, Ord a) => Expr a -> Expr a -> Expr a Source #

fromMaybe :: Columnable a => a -> Expr (Maybe a) -> Expr a Source #

sum :: (Columnable a, Num a) => Expr a -> Expr a Source #

maximum :: (Columnable a, Ord a) => Expr a -> Expr a Source #

minimum :: (Columnable a, Ord a) => Expr a -> Expr a Source #

div :: (Integral a, Columnable a) => Expr a -> Expr a -> Expr a infix 8 Source #

mod :: (Integral a, Columnable a) => Expr a -> Expr a -> Expr a Source #

reduce :: (Columnable a, Columnable b) => Expr b -> a -> (a -> b -> a) -> Expr a Source #

lift :: (Columnable a, Columnable b) => (a -> b) -> Expr a -> Expr b Source #

cast :: (Columnable a, Read a) => Text -> Expr (Maybe a) Source #

Lenient numeric / text coercion returning Maybe a. Looks up column name and coerces its values to a. Values that cannot be converted (parse failures, type mismatches) become Nothing; successfully converted values are wrapped in Just. Existing Nothing in optional source columns stays as Nothing.

eq :: (Columnable a, Eq a, a ~ BaseType a) => Expr a -> Expr a -> Expr Bool Source #

nullLift2 :: (NullLift2Op a b r (NullLift2Result a b r), Columnable (NullLift2Result a b r)) => (BaseType a -> BaseType b -> r) -> Expr a -> Expr b -> Expr (NullLift2Result a b r) Source #

Lift a binary function over nullable or non-nullable column expressions. Any Nothing operand short-circuits to Nothing in the result.

The return type is inferred via NullLift2Result: no annotation needed.

nullLift :: (NullLift1Op a r (NullLift1Result a r), Columnable (NullLift1Result a r)) => (BaseType a -> r) -> Expr a -> Expr (NullLift1Result a r) Source #

Lift a unary function over a nullable or non-nullable column expression. When the input is Maybe a, Nothing short-circuits (like fmap). When the input is plain a, the function is applied directly.

The return type is inferred via NullLift1Result: no annotation needed.

mode :: (Ord a, Columnable a, Eq a) => Expr a -> Expr a Source #

median :: (Columnable a, Real a, Unbox a) => Expr a -> Expr Double Source #

variance :: (Columnable a, Real a, Unbox a) => Expr a -> Expr Double Source #

lift2 :: (Columnable c, Columnable b, Columnable a) => (c -> b -> a) -> Expr c -> Expr b -> Expr a Source #

countAll :: Expr Int Source #

Row count, the equivalent of SQL's COUNT(*).

collect :: Columnable a => Expr a -> Expr [a] Source #

over :: Columnable a => [Text] -> Expr a -> Expr a Source #

Window function: evaluate an expression partitioned by the given columns.

Each partition computes the inner expression independently, and the result is broadcast back to every row in that partition. This is analogous to Polars' .over() or SQL OVER (PARTITION BY ...).

-- Per-country median, broadcast to every row:
F.over ["country"] (F.median (F.col @Double "amount"))

-- Deviation from group mean:
F.col @Double "amount" - F.over ["group"] (F.mean (F.col @Double "amount"))

castExpr :: (Columnable b, Columnable src, Read b) => Expr src -> Expr (Maybe b) Source #

castExprWithDefault :: (Columnable b, Columnable src, Read b) => b -> Expr src -> Expr b Source #

sumMaybe :: (Columnable a, Num a) => Expr (Maybe a) -> Expr a Source #

stddev :: (Columnable a, Real a, Unbox a) => Expr a -> Expr Double Source #

pow :: (Columnable a, Num a) => Expr a -> Int -> Expr a Source #

relu :: (Columnable a, Num a, Ord a) => Expr a -> Expr a Source #

whenPresent :: (Columnable a, Columnable b) => (a -> b) -> Expr (Maybe a) -> Expr (Maybe b) Source #

whenBothPresent :: (Columnable a, Columnable b, Columnable c) => (a -> b -> c) -> Expr (Maybe a) -> Expr (Maybe b) -> Expr (Maybe c) Source #

recode :: (Columnable a, Columnable b, Show (a, b)) => [(a, b)] -> Expr a -> Expr (Maybe b) Source #

recodeWithCondition :: (Columnable a, Columnable b) => Expr b -> [(Expr a -> Expr Bool, b)] -> Expr a -> Expr b Source #

recodeWithDefault :: (Columnable a, Columnable b, Show (a, b)) => b -> [(a, b)] -> Expr a -> Expr b Source #

bind :: forall a b m. (Columnable a, Columnable (m a), Monad m, Columnable b, Columnable (m b)) => (a -> m b) -> Expr (m a) -> Expr (m b) Source #

castWithDefault :: (Columnable a, Read a) => a -> Text -> Expr a Source #

Lenient coercion that substitutes a default for unconvertible values. Looks up column name, coerces its values to a, and uses def wherever conversion fails or the source value is Nothing.

castEither :: (Columnable a, Read a) => Text -> Expr (Either Text a) Source #

Lenient coercion returning Either T.Text a. Successfully converted values are Right; values that cannot be parsed are kept as Left with their original string representation, so the caller can inspect or handle them downstream. Existing Nothing in optional source columns becomes Left "null".

unsafeCast :: (Columnable a, Read a) => Text -> Expr a Source #

Lenient coercion for assertedly non-nullable columns. Substitutes error for Nothing, so it will crash at evaluation time if any Nothing is actually encountered. For non-nullable and fully-populated nullable columns no cost is paid.

lt :: (Columnable a, Ord a, a ~ BaseType a) => Expr a -> Expr a -> Expr Bool Source #

gt :: (Columnable a, Ord a, a ~ BaseType a) => Expr a -> Expr a -> Expr Bool Source #

leq :: (Columnable a, Ord a, Eq a, a ~ BaseType a) => Expr a -> Expr a -> Expr Bool Source #

geq :: (Columnable a, Ord a, Eq a, a ~ BaseType a) => Expr a -> Expr a -> Expr Bool Source #

topK :: (Columnable a, Ord a) => Int -> Expr a -> Expr [a] Source #

The k largest values per group.

kExtremes :: (Columnable a, Ord a) => Text -> (a -> a -> Bool) -> Int -> Expr a -> Expr [a] Source #

Top k values after applying an ordering function. Floating-point NaNs are dropped: they have no place in a total order, and admitting them would make the merge non-associative (results would depend on chunk boundaries in the lazy executor).

bottomK :: (Columnable a, Ord a) => Int -> Expr a -> Expr [a] Source #

The k smallest values per group.

isNull :: Columnable a => Expr (Maybe a) -> Expr Bool Source #

SQL spelling of isNothing.

isNotNull :: Columnable a => Expr (Maybe a) -> Expr Bool Source #

SQL spelling of isJust.

add :: (Num a, Columnable a) => Expr a -> Expr a -> Expr a #

sub :: (Num a, Columnable a) => Expr a -> Expr a -> Expr a #

mult :: (Num a, Columnable a) => Expr a -> Expr a -> Expr a #

divide :: (Fractional a, Columnable a) => Expr a -> Expr a -> Expr a #

prettyPrint :: Expr a -> String #

Render an expression as readable, width-aware pseudo-code at the default width (defaultWidth). See prettyPrintWidth to control wrapping.