Documentation
¶
Overview ¶
Package dataframe provides a general interface for managing tabular data that support filtering, aggregation and data manipulation.
This package is beta and its API is subject to change.
This package includes a decoder for CSV files which can be used to create dataframes from CSV files. The decoder is not a streaming decoder and will load the entire CSV file into memory.
The following example shows how to create a dataframe from a CSV file:
package main
import ...
var (
PickupDay = dataframe.Strings("PICKUP_DAY")
PickupTime = dataframe.Ints("PICKUP_TIME")
// ...
)
func main() {
run.Run(handler, run.Decode(dataframe.FromCSV))
}
func handler(d dataframe.DataFrame, o store.Options) (store.Solver, error) {
d = d.Filter(
PickupDay.Equals("Monday").Or(PickupDay.Equals("Tuesday")
).Filter(
PickupTime.IsInRange(16, 19),
)
// ...
}
Running the example will create a dataframe from the CSV file and pass it to the handler function. The handler function can then use the dataframe to solve the problem. To pass a CSV file to the example use the input path flag:
nextmv run local . -- \ -runner.input.path ./data.csv.gz \ -runner.output.path output.json
Deprecated: This package is deprecated and will be removed in the next major release.
Index ¶
- Constants
- func FromCSV() decode.Decoderdeprecated
- type Aggregationdeprecated
- type Aggregationsdeprecated
- type BoolColumndeprecated
- func Bools(name string) BoolColumndeprecated
- type Columndeprecated
- type Columnsdeprecated
- type DataFramedeprecated
- type DataFramesdeprecated
- type DataTypedeprecated
- type Filterdeprecated
- type Filtersdeprecated
- type FloatColumndeprecated
- func Floats(name string) FloatColumndeprecated
- type Groupsdeprecated
- type IntColumndeprecated
- func Ints(name string) IntColumndeprecated
- type NumericAggregationsdeprecated
- type StringColumndeprecated
- func Strings(name string) StringColumndeprecated
Constants ¶
const ( // Bool type representing boolean true and false values. // // Deprecated: This package is deprecated and will be removed in the next major release. Bool DataType = "bool" // Int type representing int values. // // Deprecated: This package is deprecated and will be removed in the next major release. Int = "int" // Float type representing float64 values. // // Deprecated: This package is deprecated and will be removed in the next major release. Float = "float" // String type representing string values. // // Deprecated: This package is deprecated and will be removed in the next major release. String = "string" )
Types of data in DataFrame.
Deprecated: This package is deprecated and will be removed in the next major release.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Aggregation
deprecated
type Aggregation interface {
fmt.Stringer
// Column returns the column the aggregation will be applied to.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
Column() Column
// As returns the column to be used to identify the newly created column.
// containing the aggregated value.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
As() Column
}
Aggregation defines how to aggregate rows of a group of rows in a Groups instance.
Deprecated: This package is deprecated and will be removed in the next major release.
type Aggregations
deprecated
type Aggregations []Aggregation
Aggregations is the slice of Aggregation instances.
Deprecated: This package is deprecated and will be removed in the next major release.
type BoolColumn
deprecated
type BoolColumn interface {
Column
// IsFalse creates a filter to filter all rows having value false.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
IsFalse() Filter
// IsTrue creates a filter to filter all rows having value true.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
IsTrue() Filter
// Value return the value at row for dataframe df,
// panics if out of bound.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
Value(df DataFrame, row int) bool
// Values returns all the values in the column for dataframe df.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
Values(df DataFrame) []bool
}
BoolColumn is the typed column of type Bool.
Deprecated: This package is deprecated and will be removed in the next major release.
func Bools
deprecated
func Bools(name string) BoolColumn
Bools returns a BoolColumn identified by name.
Deprecated: This package is deprecated and will be removed in the next major release.
type Column
deprecated
type Column interface {
fmt.Stringer
// Name returns the name of the column, the name is the unique identifier
// of the column within a DataFrame instance.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
Name() string
// DataType returns the type of the column.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
DataType() DataType
}
Column is a single column in a DataFrame instance. It is identified by its name and has a DataType.
Deprecated: This package is deprecated and will be removed in the next major release.
type DataFrame
deprecated
type DataFrame interface {
// Column returns a column identified by name, panics if not present.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
Column(name string) Column
// Columns returns all columns present in the dataframe.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
Columns() Columns
// Distinct returns a new DataFrame that only contains unique rows with
// respect to the specified columns. If no columns are given Distinct will
// return rows where all columns are unique.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
Distinct(columns ...Column) DataFrame
// Filter returns a new filtered DataFrame according to the filter.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
Filter(filter Filter) DataFrame
// GroupBy groups rows together for which the values of specified columns
// are the same.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
GroupBy(columns ...Column) Groups
// HasColumn reports if a columns with name is present in the dataframe.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
HasColumn(name string) bool
// AreBools returns true if column by name is of type Bool, otherwise false.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
AreBools(name string) bool
// AreInts returns true if column by name is of type Int, otherwise false.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
AreInts(name string) bool
// AreFloats returns true if column by name is of type floats, otherwise
// false.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
AreFloats(name string) bool
// AreStrings returns true if column by name is of type String, otherwise
// false.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
AreStrings(name string) bool
// Len returns the number of rows in the dataframe.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
Len() int
// Select returns a new dataframe containing only the specified columns.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
Select(columns ...Column) DataFrame
}
DataFrame is an immutable data frame that support filtering, aggregation and data manipulation.
Deprecated: This package is deprecated and will be removed in the next major release.
type DataFrames
deprecated
type DataFrames []DataFrame
DataFrames is the slice of DataFrame instances.
Deprecated: This package is deprecated and will be removed in the next major release.
type Filter
deprecated
type Filter interface {
fmt.Stringer
// And creates and returns a conjunction filter of the invoking filter
// and filter.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
And(filter Filter) Filter
// Not creates and returns a negation filter of the invoking filter.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
Not() Filter
// Or creates and returns a disjunction filter of the invoking filter
// and filter.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
Or(filter Filter) Filter
}
Filter defines how to filter columns out of a DataFrame instance.
Deprecated: This package is deprecated and will be removed in the next major release.
type FloatColumn
deprecated
type FloatColumn interface {
Column
NumericAggregations
// IsInRange creates a filter to filter all rows within range [min, max].
//
// Deprecated: This package is deprecated and will be removed in the next major release.
IsInRange(min, max float64) Filter
// Value return the value at row, panics if out of bound.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
Value(df DataFrame, row int) float64
// Values returns all the values in the column.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
Values(df DataFrame) []float64
}
FloatColumn is the typed column of type Float.
Deprecated: This package is deprecated and will be removed in the next major release.
func Floats
deprecated
func Floats(name string) FloatColumn
Floats returns a FloatColumn identified by name.
Deprecated: This package is deprecated and will be removed in the next major release.
type Groups
deprecated
type Groups interface {
// Aggregate applies the given aggregations to all row groups in the
// Groups and returns DataFrame instance where each row corresponds
// to each group.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
Aggregate(aggregations ...Aggregation) DataFrame
// DataFrames returns a slice of DataFrame where each frame represents
// the content of one group.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
DataFrames() DataFrames
}
Groups contains groups of rows produced by DataFrame.GroupBy function.
Deprecated: This package is deprecated and will be removed in the next major release.
type IntColumn
deprecated
type IntColumn interface {
Column
NumericAggregations
// IsInRange creates a filter to filter all value within range [min, max].
//
// Deprecated: This package is deprecated and will be removed in the next major release.
IsInRange(min, max int) Filter
// Value return the value at row, panics if out of bound.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
Value(df DataFrame, row int) int
// Values returns all the values in the column.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
Values(df DataFrame) []int
}
IntColumn is the typed column of type Int.
Deprecated: This package is deprecated and will be removed in the next major release.
type NumericAggregations
deprecated
type NumericAggregations interface {
// Max creates an aggregation which reports the maximum value using
// name as.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
Max(as string) Aggregation
// Min creates an aggregation which reports the minimum value using
// name as.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
Min(as string) Aggregation
// Sum creates an aggregation which reports the sum of values using
// name as.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
Sum(as string) Aggregation
}
NumericAggregations defines the possible aggregations which can be applied on columns of type Float and Int.
Deprecated: This package is deprecated and will be removed in the next major release.
type StringColumn
deprecated
type StringColumn interface {
Column
// Equals creates a filter to filter all rows having value value.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
Equals(value string) Filter
// Value return the value at row, panics if out of bound.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
Value(df DataFrame, row int) string
// Values returns all the values in the column.
//
// Deprecated: This package is deprecated and will be removed in the next major release.
Values(df DataFrame) []string
}
StringColumn is the typed column of type String.
Deprecated: This package is deprecated and will be removed in the next major release.
func Strings
deprecated
func Strings(name string) StringColumn
Strings returns a StringColumn identified by name.
Deprecated: This package is deprecated and will be removed in the next major release.