| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
DataFrame.Internal.DataFrame
Synopsis
- data DataFrame = DataFrame {
- columns :: Vector Column
- columnIndices :: Map Text Int
- dataframeDimensions :: (Int, Int)
- data GroupedDataFrame = Grouped {
- fullDataframe :: DataFrame
- groupedColumns :: [Text]
- valueIndices :: Vector Int
- offsets :: Vector Int
- toMarkdownTable :: DataFrame -> Text
- asText :: DataFrame -> Bool -> Text
- empty :: DataFrame
- getColumn :: Text -> DataFrame -> Maybe Column
- unsafeGetColumn :: Text -> DataFrame -> Column
- null :: DataFrame -> Bool
- toFloatMatrix :: DataFrame -> Either DataFrameException (Vector (Vector Float))
- toDoubleMatrix :: DataFrame -> Either DataFrameException (Vector (Vector Double))
- toIntMatrix :: DataFrame -> Either DataFrameException (Vector (Vector Int))
- columnAsVector :: Columnable a => Text -> DataFrame -> Vector a
- columnAsIntVector :: Text -> DataFrame -> Either DataFrameException (Vector Int)
- columnAsDoubleVector :: Text -> DataFrame -> Either DataFrameException (Vector Double)
- columnAsFloatVector :: Text -> DataFrame -> Either DataFrameException (Vector Float)
Documentation
Constructors
| DataFrame | |
Fields
| |
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.
Constructors
| Grouped | |
Fields
| |
Instances
| Show GroupedDataFrame Source # | |
Defined in DataFrame.Internal.DataFrame Methods showsPrec :: Int -> GroupedDataFrame -> ShowS # show :: GroupedDataFrame -> String # showList :: [GroupedDataFrame] -> ShowS # | |
| Eq GroupedDataFrame Source # | |
Defined in DataFrame.Internal.DataFrame Methods (==) :: GroupedDataFrame -> GroupedDataFrame -> Bool # (/=) :: GroupedDataFrame -> GroupedDataFrame -> Bool # | |
toMarkdownTable :: DataFrame -> Text Source #
For showing the dataframe as markdown in notebooks.
getColumn :: Text -> DataFrame -> Maybe Column Source #
Safely retrieves a column by name from the dataframe.
Returns Nothing if the column does not exist.
Examples
>>>getColumn "age" dfJust (UnboxedColumn ...)
>>>getColumn "nonexistent" dfNothing
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
ColumnNotFoundException- if the column with the given name does not exist
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
>>>columnAsVector @Int "age" df[25, 30, 35, ...]
>>>columnAsVector @Text "name" df["Alice", "Bob", "Charlie", ...]
Throws
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.