Module

Data.DataFrame

Package
purescript-dataframe
Repository
gabysbrain/purescript-dataframe

#DataFrame Source

newtype DataFrame r

A DataFrame is an ordered set of rows of type r.

Constructors

Instances

#Query Source

type Query df r = Reader df r

A query result gives both the original input and the query result. Queries can be chained together.

The idea of the query result is that maintaining the original input is helpful for things like histograms and graphs you want the original frame for computing ranges for axes and bin widths

The idea of the query result is to maintain the orignal data frame:

#init Source

init :: forall r f. Foldable f => f r -> DataFrame r

Create a data frame from an arbitrary Foldable. Each item of the Foldable will become a "row" of the DataFrame.

#runQuery Source

runQuery :: forall b a. Query a b -> a -> b

Evaluate the query given the starting input. Returns the result of the Query.

#rows Source

rows :: forall r. DataFrame r -> Int

The number of "rows" in the DataFrame.

#reset Source

reset :: forall df. Query df df

Get back the original input so that it can be chained into annother query.

#filter Source

filter :: forall r. (r -> Boolean) -> Query (DataFrame r) (DataFrame r)

Create a query that will filter a dataframe so that it only contains rows where the filter function returns true.

#group Source

group :: forall g r. Ord g => (r -> g) -> Query (DataFrame r) (DataFrame { data :: DataFrame r, group :: g })

Group the rows of the DataFrame based on the grouping function.

#count Source

count :: forall g r. Ord g => (r -> g) -> Query (DataFrame r) (DataFrame { count :: Int, group :: g })

Count the size of each group of rows in the dataframe.

#summarize Source

summarize :: forall x r. (r -> x) -> Query (DataFrame r) (Array x)

Reduce each row to another value and then get an array of that value. Useful for feeding to functions like maximum, average, etc.

#mutate Source

mutate :: forall s r. (r -> s) -> Query (DataFrame r) (DataFrame s)

Change each row of the DataFrame using the conversion function.

Can be used, e.g., to do column filtering

#sort Source

sort :: forall r. (r -> r -> Ordering) -> Query (DataFrame r) (DataFrame r)

Sort the rows of the dataframe by the given sorting function.

#trim Source

trim :: forall r. Int -> Query (DataFrame r) (DataFrame r)

Only keep all but the first n rows of the DataFrame.

#chain Source

chain :: forall t s r. Query r s -> Query s t -> Query r t

Run 2 queries and return the first input as the context.

#_groups Source

_groups :: forall g a. Ord g => (a -> g) -> Array a -> Map g (Array a)

#_toGroupInfo Source

_toGroupInfo :: forall g a. Array (Tuple g (Array a)) -> Array { data :: DataFrame a, group :: g }

#_toCountInfo Source

_toCountInfo :: forall g a. Array (Tuple g (Array a)) -> Array { count :: Int, group :: g }