Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/DataFrame/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import DataFrame.Internal.Column (Columnable)
import DataFrame.Internal.Expression (Expr (..))

import qualified Data.Text as T
import System.Random

-- A re-implementation of the state monad.
-- `mtl` might be too heavy a dependency just to get
Expand Down Expand Up @@ -61,6 +62,9 @@ renameM expr newName = deriveM newName expr
filterWhereM :: Expr Bool -> FrameM ()
filterWhereM p = modifyM (D.filterWhere p)

sampleM :: (RandomGen g) => g -> Double -> FrameM ()
sampleM pureGen p = modifyM (D.sample pureGen p)

filterJustM :: (Columnable a) => Expr (Maybe a) -> FrameM (Expr a)
filterJustM (Col name) = FrameM $ \df ->
let df' = D.filterJust name df
Expand Down
18 changes: 15 additions & 3 deletions src/DataFrame/Operations/Subset.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,23 @@ import qualified Prelude

import Control.Exception (throw)
import Data.Function ((&))
import Data.Maybe (fromJust, fromMaybe, isJust, isNothing)
import Data.Maybe (
fromJust,
fromMaybe,
isJust,
isNothing,
)
import Data.Type.Equality (TestEquality (..))
import DataFrame.Errors (DataFrameException (..), TypeErrorContext (..))
import DataFrame.Errors (
DataFrameException (..),
TypeErrorContext (..),
)
import DataFrame.Internal.Column
import DataFrame.Internal.DataFrame (DataFrame (..), empty, getColumn)
import DataFrame.Internal.DataFrame (
DataFrame (..),
empty,
getColumn,
)
import DataFrame.Internal.Expression
import DataFrame.Internal.Interpreter
import DataFrame.Operations.Core
Expand Down