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
3 changes: 1 addition & 2 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ chipotle = do
print $ D.take 10 f

-- Create a total_price column that is quantity * item_price
let multiply (a :: Int) (b :: Double) = fromIntegral a * b
let withTotalPrice = D.deriveFrom (["quantity", "item_price"], D.func multiply) "total_price" f
let withTotalPrice = D.derive "total_price" (D.lift fromIntegral (D.col @Int "quantity") * D.col @Double"item_price") f

-- sample a filtered subset of the dataframe
putStrLn "Sample dataframe"
Expand Down
2 changes: 2 additions & 0 deletions dataframe.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ source-repository head
library
exposed-modules: DataFrame
other-modules: DataFrame.Internal.Types,
DataFrame.Internal.Expression,
DataFrame.Internal.Function,
DataFrame.Internal.Parsing,
DataFrame.Internal.Column,
Expand Down Expand Up @@ -60,6 +61,7 @@ executable dataframe
main-is: Main.hs
other-modules: DataFrame,
DataFrame.Internal.Types,
DataFrame.Internal.Expression,
DataFrame.Internal.Function,
DataFrame.Internal.Parsing,
DataFrame.Internal.Column,
Expand Down
2 changes: 1 addition & 1 deletion docs/coming_from_dplyr.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ starwars
|> D.selectRange ("name", "mass")
-- mass and height are optionals so we combine them with
-- Haskell's Applicative operators.
|> D.deriveFrom (["mass", "height"], D.func (\w h -> bmi <$> w <*> h)) "bmi"
|> D.derive "bmi" (lift2 (/) (lift fromIntegral (col @Int "mass")) (lift fromIntegral (col@ Int "height")))
|> D.take 10
```

Expand Down
1 change: 1 addition & 0 deletions src/DataFrame.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module DataFrame
where

import DataFrame.Internal.Types as D
import DataFrame.Internal.Expression as D
import DataFrame.Internal.Function as D
import DataFrame.Internal.Parsing as D
import DataFrame.Internal.Column as D
Expand Down
4 changes: 2 additions & 2 deletions src/DataFrame/Display/Terminal/Plot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{-# LANGUAGE GADTs #-}
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE FlexibleContexts #-}
module DataFrame.Display.Terminal.Plot where

import qualified Data.List as L
Expand All @@ -19,9 +20,8 @@ import Control.Monad ( forM_, forM )
import Data.Bifunctor ( first )
import Data.Char ( ord, chr )
import DataFrame.Display.Terminal.Colours
import DataFrame.Internal.Column (Column(..))
import DataFrame.Internal.Column (Column(..), Columnable)
import DataFrame.Internal.DataFrame (DataFrame(..))
import DataFrame.Internal.Types (Columnable)
import DataFrame.Operations.Core
import Data.Maybe (fromMaybe)
import Data.Typeable (Typeable)
Expand Down
4 changes: 2 additions & 2 deletions src/DataFrame/Errors.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ data DataFrameException where
-> T.Text -- ^ call point
-> DataFrameException
TypeMismatchException' :: forall a . (Typeable a)
=> TypeRep a -- ^ expected type
-> String -- ^ given type
=> TypeRep a -- ^ given type
-> String -- ^ expected type
-> T.Text -- ^ column name
-> T.Text -- ^ call point
-> DataFrameException
Expand Down
Loading