dataframe-0.3.3.3: A fast, safe, and intuitive DataFrame library.
Safe HaskellNone
LanguageHaskell2010

DataFrame.Internal.DataFrame

Synopsis

Documentation

data DataFrame Source #

Constructors

DataFrame 

Fields

Instances

Instances details
Monoid DataFrame Source # 
Instance details

Defined in DataFrame.Operations.Merge

Semigroup DataFrame Source #

Vertically merge two dataframes using shared columns. Columns that exist in only one dataframe are padded with Nothing.

Instance details

Defined in DataFrame.Operations.Merge

Show DataFrame Source # 
Instance details

Defined in DataFrame.Internal.DataFrame

Eq DataFrame Source # 
Instance details

Defined in DataFrame.Internal.DataFrame

data GroupedDataFrame Source #

A record that contains information about how and what rows are grouped in the dataframe. This can only be used with aggregate.

toMarkdownTable :: DataFrame -> Text Source #

For showing the dataframe as markdown in notebooks.

empty :: DataFrame Source #

O(1) Creates an empty dataframe

getColumn :: Text -> DataFrame -> Maybe Column Source #

Safely retrieves a column by name from the dataframe.

Returns Nothing if the column does not exist.

Examples

Expand
>>> getColumn "age" df
Just (UnboxedColumn ...)
>>> getColumn "nonexistent" df
Nothing

unsafeGetColumn :: Text -> DataFrame -> Column Source #

Retrieves a column by name from the dataframe, throwing an exception if not found.

This is an unsafe version of getColumn that throws ColumnNotFoundException if the column does not exist. Use this when you are certain the column exists.

Throws

Expand

null :: DataFrame -> Bool Source #

Checks if the dataframe is empty (has no columns).

Returns True if the dataframe has no columns, False otherwise. Note that a dataframe with columns but no rows is not considered null.

toFloatMatrix :: DataFrame -> Either DataFrameException (Vector (Vector Float)) Source #

Returns a dataframe as a two dimensional vector of floats.

Converts all columns in the dataframe to float vectors and transposes them into a row-major matrix representation.

This is useful for handing data over into ML systems.

Returns Left with an error if any column cannot be converted to floats.

toDoubleMatrix :: DataFrame -> Either DataFrameException (Vector (Vector Double)) Source #

Returns a dataframe as a two dimensional vector of doubles.

Converts all columns in the dataframe to double vectors and transposes them into a row-major matrix representation.

This is useful for handing data over into ML systems.

Returns Left with an error if any column cannot be converted to doubles.

toIntMatrix :: DataFrame -> Either DataFrameException (Vector (Vector Int)) Source #

Returns a dataframe as a two dimensional vector of ints.

Converts all columns in the dataframe to int vectors and transposes them into a row-major matrix representation.

This is useful for handing data over into ML systems.

Returns Left with an error if any column cannot be converted to ints.

columnAsVector :: Columnable a => Text -> DataFrame -> Vector a Source #

Get a specific column as a vector.

You must specify the type via type applications.

Examples

Expand
>>> columnAsVector @Int "age" df
[25, 30, 35, ...]
>>> columnAsVector @Text "name" df
["Alice", "Bob", "Charlie", ...]

Throws

Expand
  • error - if the column type doesn't match the requested type

columnAsIntVector :: Text -> DataFrame -> Either DataFrameException (Vector Int) Source #

Retrieves a column as an unboxed vector of Int values.

Returns Left with a DataFrameException if the column cannot be converted to ints. This may occur if the column contains non-numeric data or values outside the Int range.

columnAsDoubleVector :: Text -> DataFrame -> Either DataFrameException (Vector Double) Source #

Retrieves a column as an unboxed vector of Double values.

Returns Left with a DataFrameException if the column cannot be converted to doubles. This may occur if the column contains non-numeric data.

columnAsFloatVector :: Text -> DataFrame -> Either DataFrameException (Vector Float) Source #

Retrieves a column as an unboxed vector of Float values.

Returns Left with a DataFrameException if the column cannot be converted to floats. This may occur if the column contains non-numeric data.