Frame
Namespace: Deedle
Attributes:
[<CompilationRepresentation(4)>]
The Frame
module provides an F#-friendly API for working with data frames.
The module follows the usual desing for collection-processing in F#, so the
functions work well with the pipelining operator (|>
). For example, given
a frame with two columns representing prices, we can use Frame.diff
and
numerical operators to calculate daily returns like this:
1: 2: 3: 4: |
|
Note that the Stats.mean
operation is overloaded and works both on series
(returning a number) and on frames (returning a series).
The functions in this module are designed to be used from F#. For a C#-friendly
API, see the FrameExtensions
type. For working with individual series, see the
Series
module. The functions in the Frame
module are grouped in a number of
categories and documented below.
Table of contents
- Accessing frame data and lookup
- Frame transformations
- Grouping, windowing and chunking
- Hierarchical index operations
- Joining, merging and zipping
- Missing values
- Processing frames with exceptions
- Sorting and index manipulation
Accessing frame data and lookup
Functions in this category provide access to the values in the fame. You can also add and remove columns from a frame (which both return a new value).
-
addCol
,replaceCol
anddropCol
can be used to create a new data frame with a new column, by replacing an existing column with a new one, or by dropping an existing column -
cols
androws
return the columns or rows of a frame as a series containing objects;getCols
andgetRows
return a generic series and cast the values to the type inferred from the context (columns or rows of incompatible types are skipped);getNumericCols
returns columns of a type convertible tofloat
for convenience. -
You can get a specific row or column using
get[Col|Row]
orlookup[Col|Row]
functions. Thelookup
variant lets you specify lookup behavior for key matching (e.g. find the nearest smaller key than the specified value). There are also[try]get
and[try]Lookup
functions that return optional values and functions returning entire observations (key together with the series). -
sliceCols
andsliceRows
return a sub-frame containing only the specified columns or rows. Finally,toArray2D
returns the frame data as a 2D array.
Functions and values
Frame transformations
Functions in this category perform standard transformations on data frames including projections, filtering, taking some sub-frame of the frame, aggregating values using scanning and so on.
Projection and filtering functions such as [map|filter][Cols|Rows]
call the
specified function with the column or row key and an ObjectSeries<'K>
representing
the column or row. You can use functions ending with Values
(such as mapRowValues
)
when you do not require the row key, but only the row series; mapRowKeys
and
mapColKeys
can be used to transform the keys.
You can use reduceValues
to apply a custom reduction to values of columns. Other
aggregations are available in the Stats
module. You can also get a row with the
greaterst or smallest value of a given column using [min|max]RowBy
.
The functions take[Last]
and skip[Last]
can be used to take a sub-frame of the
original source frame by skipping a specified number of rows. Note that this
does not require an ordered frame and it ignores the index - for index-based lookup
use slicing, such as df.Rows.[lo .. hi]
, instead.
Finally the shift
function can be used to obtain a frame with values shifted by
the specified offset. This can be used e.g. to get previous value for each key using
Frame.shift 1 df
. The diff
function calculates difference from previous value using
df - (Frame.shift offs df)
.
Functions and values
Function or value | Description | ||
diff offset frame
Signature: offset:int -> frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'R, 'C Attributes: [<CompiledName("Diff")>] |
Returns a frame with columns containing difference between an original value and
a value at the specified offset. For example, calling
Columns that cannot be converted to Parameters
CompiledName: |
||
filterCols f frame
Signature: f:('C -> ObjectSeries<'R> -> bool) -> frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'C, 'R Attributes: [<CompiledName("WhereColumns")>] |
Returns a new data frame containing only the columns of the input frame
for which the specified predicate returns Parameters
CompiledName: |
||
filterColValues f frame
Signature: f:(ObjectSeries<'R> -> bool) -> frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'R, 'C Attributes: [<CompiledName("WhereColumnValues")>] |
Returns a new data frame containing only the columns of the input frame
for which the specified predicate returns Parameters
CompiledName: |
||
filterRows f frame
Signature: f:('R -> ObjectSeries<'C> -> bool) -> frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'R, 'C Attributes: [<CompiledName("WhereRows")>] |
Returns a new data frame containing only the rows of the input frame
for which the specified predicate returns Parameters
CompiledName: |
||
filterRowsBy column value frame
Signature: column:'C -> value:'V -> frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'C, 'V, 'R Attributes: [<CompiledName("WhereRowsBy")>] |
Returns a new data frame containing only the rows of the input frame
for which the specified Parameters
CompiledName: |
||
filterRowValues f frame
Signature: f:(ObjectSeries<'C> -> bool) -> frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'C, 'R Attributes: [<CompiledName("WhereRowValues")>] |
Returns a new data frame containing only the rows of the input frame
for which the specified predicate returns Parameters
CompiledName: |
||
map f frame
Signature: f:('R -> 'C -> '?689531 -> '?689532) -> frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'R, 'C, '?689531, '?689532 |
Builds a new data frame whose values are the results of applying the specified function on these values, but only for those columns which can be converted to the appropriate type for input to the mapping function. Parameters
|
||
mapColKeys f frame
Signature: f:('C -> '?689521) -> frame:Frame<'R,'C> -> Frame<'R,'?689521>
Type parameters: 'C, '?689521, 'R Attributes: [<CompiledName("SelectColumnKeys")>] |
Builds a new data frame whose column keys are the results of applying the specified function on the column keys of the original data frame. Parameters
CompiledName: |
||
mapCols f frame
Signature: f:('C -> ObjectSeries<'R> -> '?689512) -> frame:Frame<'R,'C> -> Frame<'?689513,'C>
Type parameters: 'C, 'R, '?689512, '?689513 Attributes: [<CompiledName("SelectColumns")>] |
Builds a new data frame whose columns are the results of applying the specified function on the columns of the input data frame. The function is called with the column key and object series that represents the column data. Parameters
CompiledName: |
||
mapColValues f frame
Signature: f:(ObjectSeries<'R> -> '?689516) -> frame:Frame<'R,'C> -> Frame<'?689517,'C>
Type parameters: 'R, '?689516, '?689517, 'C Attributes: [<CompiledName("SelectColumnValues")>] |
Builds a new data frame whose columns are the results of applying the specified
function on the columns of the input data frame. The function is called
with an object series that represents the column data (use Parameters
CompiledName: |
||
mapRowKeys f frame
Signature: f:('R1 -> 'R2) -> frame:Frame<'R1,'C> -> Frame<'R2,'C>
Type parameters: 'R1, 'R2, 'C Attributes: [<CompiledName("SelectRowKeys")>] |
Builds a new data frame whose row keys are the results of applying the specified function on the row keys of the original data frame. Parameters
CompiledName: |
||
mapRows f frame
Signature: f:('R -> ObjectSeries<'C> -> 'V) -> frame:Frame<'R,'C> -> Series<'R,'V>
Type parameters: 'R, 'C, 'V Attributes: [<CompiledName("SelectRows")>] |
Builds a new data frame whose rows are the results of applying the specified function on the rows of the input data frame. The function is called with the row key and object series that represents the row data. Parameters
CompiledName: |
||
mapRowValues f frame
Signature: f:(ObjectSeries<'C> -> 'V) -> frame:Frame<'R,'C> -> Series<'R,'V>
Type parameters: 'C, 'V, 'R Attributes: [<CompiledName("SelectRowValues")>] |
Builds a new data frame whose rows are the results of applying the specified
function on the rows of the input data frame. The function is called
with an object series that represents the row data (use Parameters
CompiledName: |
||
mapValues f frame
Signature: f:('?689524 -> '?689525) -> frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: '?689524, '?689525, 'R, 'C Attributes: [<CompiledName("MapValues")>] |
Parameters
CompiledName: |
||
maxRowBy column frame
Signature: column:'C -> frame:Frame<'R,'C> -> ('R * ObjectSeries<'C>) option
Type parameters: 'C, 'R Attributes: [<CompiledName("MaxRowBy")>] |
Returns a row of the data frame which has the greatest value of the
specified CompiledName: |
||
minRowBy column frame
Signature: column:'C -> frame:Frame<'R,'C> -> ('R * ObjectSeries<'C>) option
Type parameters: 'C, 'R Attributes: [<CompiledName("MinRowBy")>] |
Returns a row of the data frame which has the smallest value of the
specified CompiledName: |
||
reduceValues op frame
Signature: op:('T -> 'T -> 'T) -> frame:Frame<'R,'C> -> Series<'C,'T>
Type parameters: 'T, 'R, 'C Attributes: [<CompiledName("ReduceValues")>] |
Returns a series that contains the results of aggregating each column
to a single value. The function takes columns that can be converted to
the type expected by the specified ExampleThe following sums the values in each column that can be converted to
Multiple items
val float : value:'T -> float (requires member op_Explicit) -------------------- type float = System.Double -------------------- type float<'Measure> = float CompiledName: |
||
shift offset frame
Signature: offset:int -> frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'R, 'C Attributes: [<CompiledName("Shift")>] |
Returns a frame with columns shifted by the specified offset. When the offset is
positive, the values are shifted forward and first
Parameters
RemarksIf you want to calculate the difference, e.g. CompiledName: |
||
skip count frame
Signature: count:int -> frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'R, 'C Attributes: [<CompiledName("Skip")>] |
Returns a frame that contains the data from the original frame,
except for the first CompiledName: |
||
skipLast count frame
Signature: count:int -> frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'R, 'C Attributes: [<CompiledName("SkipLast")>] |
Returns a frame that contains the data from the original frame,
except for the last CompiledName: |
||
take count frame
Signature: count:int -> frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'R, 'C Attributes: [<CompiledName("Take")>] |
Returns a frame that contains the specified CompiledName: |
||
takeLast count frame
Signature: count:int -> frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'R, 'C Attributes: [<CompiledName("TakeLast")>] |
Returns a frame that contains the specified CompiledName: |
Grouping, windowing and chunking
The basic grouping functions in this category can be used to group the rows of a
data frame by a specified projection or column to create a frame with hierarchical
index such as Frame<'K1 * 'K2, 'C>
. The functions always aggregate rows, so if you
want to group columns, you need to use Frame.transpose
first.
The function groupRowsBy
groups rows by the value of a specified column. Use
groupRowsBy[Int|Float|String...]
if you want to specify the type of the column in
an easier way than using type inference; groupRowsUsing
groups rows using the
specified projection function and groupRowsByIndex
projects the grouping key just
from the row index.
More advanced functions include: aggregateRowsBy
which groups the rows by a
specified sequence of columns and aggregates each group into a single value;
pivotTable
implements the pivoting operation as documented in the
tutorials.
The melt
and unmelt
functions turn the data frame into a single data frame
containing columns Row
, Column
and Value
containing the data of the original
frame; melt
can be used to turn this representation back into an original frame.
A simple windowing functions that are exposed for an entire frame operations are
window
and windowInto
. For more complex windowing operations, you currently have
to use mapRows
or mapCols
and apply windowing on individual series.
Functions and values
Function or value | Description |
aggregateRowsBy(...)
Signature: groupBy:seq<'C> -> aggBy:seq<'C> -> aggFunc:(Series<'R,'V1> -> 'V2) -> frame:Frame<'R,'C> -> Frame<int,'C>
Type parameters: 'C, 'R, 'V1, 'V2 Attributes: [<CompiledName("AggregateRowsBy")>] |
Returns a data frame whose rows are grouped by Parameters
CompiledName: |
groupRowsBy column frame
Signature: column:'C -> frame:Frame<'R,'C> -> Frame<('K * 'R),'C>
Type parameters: 'C, 'R, 'K Attributes: [<CompiledName("GroupRowsBy")>] |
Group rows of a data frame using the specified CompiledName: |
groupRowsByBool column frame
Signature: column:'C -> frame:Frame<'R,'C> -> Frame<(bool * 'R),'C>
Type parameters: 'C, 'R Attributes: [<CompiledName("GroupRowsByBool")>] |
Groups the rows of a frame by a specified column in the same way as CompiledName: |
groupRowsByIndex keySelector frame
Signature: keySelector:('R -> 'K) -> frame:Frame<'R,'C> -> Frame<('K * 'R),'C>
Type parameters: 'R, 'K, 'C Attributes: [<CompiledName("GroupRowsByIndex")>] |
Group rows of a data frame using the specified CompiledName: |
groupRowsByInt column frame
Signature: column:'C -> frame:Frame<'R,'C> -> Frame<(int * 'R),'C>
Type parameters: 'C, 'R Attributes: [<CompiledName("GroupRowsByInt")>] |
Groups the rows of a frame by a specified column in the same way as CompiledName: |
groupRowsByObj column frame
Signature: column:'C -> frame:Frame<'R,'C> -> Frame<(obj * 'R),'C>
Type parameters: 'C, 'R Attributes: [<CompiledName("GroupRowsByObj")>] |
Groups the rows of a frame by a specified column in the same way as CompiledName: |
groupRowsByString column frame
Signature: column:'C -> frame:Frame<'R,'C> -> Frame<(string * 'R),'C>
Type parameters: 'C, 'R Attributes: [<CompiledName("GroupRowsByString")>] |
Groups the rows of a frame by a specified column in the same way as CompiledName: |
groupRowsUsing selector frame
Signature: selector:('R -> ObjectSeries<'C> -> 'K) -> frame:Frame<'R,'C> -> Frame<('K * 'R),'C>
Type parameters: 'R, 'C, 'K Attributes: [<CompiledName("GroupRowsUsing")>] |
Group rows of a data frame using the specified CompiledName: |
melt(frame)
Signature: frame:Frame<'R,'C> -> Frame<int,string>
Type parameters: 'R, 'C Attributes: [<CompiledName("Melt")>] |
Returns a data frame with three columns named CompiledName: |
pivotTable rowGrp colGrp op frame
Signature: rowGrp:('R -> ObjectSeries<'C> -> 'RNew) -> colGrp:('R -> ObjectSeries<'C> -> 'CNew) -> op:(Frame<'R,'C> -> 'T) -> frame:Frame<'R,'C> -> Frame<'RNew,'CNew>
Type parameters: 'R, 'C, 'RNew, 'CNew, 'T Attributes: [<CompiledName("PivotTable")>] |
Creates a new data frame resulting from a 'pivot' operation. Consider a denormalized data
frame representing a table: column labels are field names & table values are observations
of those fields. pivotTable buckets the rows along two axes, according to the results of
the functions Parameters
CompiledName: |
stack(frame)
Signature: frame:Frame<'R,'C> -> Frame<int,string>
Type parameters: 'R, 'C Attributes: [<Obsolete("The Frame.Stack method has been renamed to Frame.Melt")>] [<CompiledName("Stack")>] |
WARNING: This API is obsolete
The Frame.Stack method has been renamed to Frame.Melt Returns a data frame with three columns named CompiledName: |
unmelt(frame)
Signature: frame:Frame<'O,string> -> Frame<'R,'C>
Type parameters: 'O, 'R, 'C Attributes: [<CompiledName("Unmelt")>] |
This function is the opposite of CompiledName: |
unstack(frame)
Signature: frame:Frame<'O,string> -> Frame<'R,'C>
Type parameters: 'O, 'R, 'C Attributes: [<Obsolete("The Frame.UnStack method has been renamed to Frame.Unmelt")>] [<CompiledName("UnStack")>] |
WARNING: This API is obsolete
The Frame.UnStack method has been renamed to Frame.Unmelt This function is the opposite of CompiledName: |
window size frame
Signature: size:int -> frame:Frame<'R,'C> -> Series<'R,Frame<'R,'C>>
Type parameters: 'R, 'C Attributes: [<CompiledName("Window")>] |
Creates a sliding window using the specified size. The result is a series containing data frames that represent individual windows. This function skips incomplete chunks. Parameters
CompiledName: |
windowInto size f frame
Signature: size:int -> f:(Frame<'R,'C> -> 'c) -> frame:Frame<'R,'C> -> Series<'R,'c>
Type parameters: 'R, 'C, 'c Attributes: [<CompiledName("WindowInto")>] |
Creates a sliding window using the specified size and then applies the provided
value selector Parameters
CompiledName: |
Hierarchical index operations
A data frame has a hierarchical row index if the row index is formed by a tuple, such as
Frame<'R1 * 'R2, 'C>
. Frames of this kind are returned, for example, by the grouping
functions such as Frame.groupRowsBy
. The functions in this category provide ways for
working with data frames that have hierarchical row keys.
The functions applyLevel
and reduceLevel
can be used to reduce values according to
one of the levels. The applyLevel
function takes a reduction of type Series<'K, 'T> -> 'T
while reduceLevel
reduces individual values using a function of type 'T -> 'T -> 'T
.
The functions nest
and unnest
can be used to convert between frames with
hierarchical indices (Frame<'K1 * 'K2, 'C>
) and series of frames that represent
individual groups (Series<'K1, Frame<'K2, 'C>>
). The nestBy
function can be
used to perform group by operation and return the result as a series of frems.
Functions and values
Function or value | Description |
applyLevel levelSel op frame
Signature: levelSel:('R -> 'K) -> op:(Series<'R,'T> -> 'T) -> frame:Frame<'R,'C> -> Frame<'K,'C>
Type parameters: 'R, 'K, 'T, 'C Attributes: [<CompiledName("ApplyLevel")>] |
RemarksThis function reduces a series of values using a function CompiledName: |
nest(frame)
Signature: frame:Frame<('R1 * 'R2),'C> -> Series<'R1,Frame<'R2,'C>>
Type parameters: 'R1, 'R2, 'C Attributes: [<CompiledName("Nest")>] |
Given a frame with two-level row index, returns a series indexed by the first
part of the key, containing frames representing individual groups. This function
can be used if you want to perform a transformation individually on each group
(e.g. using CompiledName: |
nestBy keySelector frame
Signature: keySelector:('K2 -> 'K1) -> frame:Frame<'K2,'C> -> Series<'K1,Frame<'K2,'C>>
Type parameters: 'K2, 'K1, 'C Attributes: [<CompiledName("NestBy")>] |
Given a data frame, use the specified CompiledName: |
reduceLevel levelSel op frame
Signature: levelSel:('R -> 'K) -> op:('T -> 'T -> 'T) -> frame:Frame<'R,'C> -> Frame<'K,'C>
Type parameters: 'R, 'K, 'T, 'C Attributes: [<CompiledName("ReduceLevel")>] |
RemarksThis function reduces values using a function CompiledName: |
unnest(series)
Signature: series:Series<'R1,Frame<'R2,'C>> -> Frame<('R1 * 'R2),'C>
Type parameters: 'R1, 'R2, 'C Attributes: [<CompiledName("Unnest")>] |
Given a series of frames, returns a new data frame with two-level hierarchical
row index, using the series keys as the first component. This function is the
dual of CompiledName: |
Joining, merging and zipping
The simplest way to join two frames is to use the join
operation which can be used to
perform left, right, outer or inner join of two frames. When the row keys of the frames do
not match exactly, you can use joinAlign
which takes an additional parameter that specifies
how to find matching key in left/right join (e.g. by taking the nearest smaller available key).
Frames that do not contian overlapping values can be combined using merge
(when combining
just two frames) or using mergeAll
(for larger number of frames). Tha latter is optimized
to work well for a large number of data frames.
Finally, frames with overlapping values can be combined using zip
. It takes a function
that is used to combine the overlapping values. A zipAlign
function provides a variant
with more flexible row key matching (as in joinAlign
)
Functions and values
Function or value | Description |
join kind frame1 frame2
Signature: kind:JoinKind -> frame1:Frame<'R,'C> -> frame2:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'R, 'C Attributes: [<CompiledName("Join")>] |
Join two data frames. The columns of the joined frames must not overlap and their
rows are aligned and transformed according to the specified join kind.
For more alignment options on ordered frames, see Parameters
CompiledName: |
joinAlign kind lookup frame1 frame2
Signature: kind:JoinKind -> lookup:Lookup -> frame1:Frame<'R,'C> -> frame2:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'R, 'C Attributes: [<CompiledName("JoinAlign")>] |
Join two data frames. The columns of the joined frames must not overlap and their
rows are aligned and transformed according to the specified join kind.
When the index of both frames is ordered, it is possible to specify Parameters
CompiledName: |
merge frame1 frame2
Signature: frame1:Frame<'R,'C> -> frame2:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'R, 'C Attributes: [<CompiledName("Merge")>] |
Append two data frames with non-overlapping values. The operation takes the union of columns and rows of the source data frames and then unions the values. An exception is thrown when both data frames define value for a column/row location, but the operation succeeds if one frame has a missing value at the location. Note that the rows are not automatically reindexed to avoid overlaps. This means that when a frame has rows indexed with ordinal numbers, you may need to explicitly reindex the row keys before calling append. Parameters
CompiledName: |
mergeAll(frames)
Signature: frames:seq<Frame<'R,'C>> -> Frame<'R,'C>
Type parameters: 'R, 'C Attributes: [<CompiledName("MergeAll")>] |
Append a sequence of data frames with non-overlapping values. The operation takes the union of columns and rows of the source data frames and then unions the values. An exception is thrown when both data frames define value for a column/row location, but the operation succeeds if one all frames but one has a missing value at the location. Note that the rows are not automatically reindexed to avoid overlaps. This means that when a frame has rows indexed with ordinal numbers, you may need to explicitly reindex the row keys before calling append. CompiledName: |
strConcat frame1 frame2
Signature: frame1:Frame<'R,'C> -> frame2:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'R, 'C Attributes: [<CompiledName("StrConcat")>] |
Piecewise concatenate two frames of string values CompiledName: |
zip op frame1 frame2
Signature: op:('V1 -> 'V2 -> 'V) -> frame1:Frame<'R,'C> -> frame2:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'V1, 'V2, 'V, 'R, 'C Attributes: [<CompiledName("ZipInto")>] |
Aligns two data frames using both column index and row index and apply the specified operation
on values of a specified type that are available in both data frames. This overload uses
Once aligned, the call Parameters
CompiledName: |
zipAlign(...)
Signature: columnKind:JoinKind -> rowKind:JoinKind -> lookup:Lookup -> op:('V1 -> 'V2 -> 'V) -> frame1:Frame<'R,'C> -> frame2:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'V1, 'V2, 'V, 'R, 'C Attributes: [<CompiledName("ZipAlignInto")>] |
Aligns two data frames using both column index and row index and apply the specified operation
on values of a specified type that are available in both data frames. The parameters Once aligned, the call Parameters
CompiledName: |
Missing values
This group of functions provides a way of working with missing values in a data frame. The category provides the following functions that can be used to fill missing values:
fillMissingWith
fills missing values with a specified constantfillMissingUsing
calls a specified function for every missing valuefillMissing
and variants propagates values from previous/later keys
We use the terms sparse and dense to denote series that contain some missing values
or do not contain any missing values, respectively. The functions denseCols
and
denseRows
return a series that contains only dense columns or rows and all sparse
rows or columns are replaced with a missing value. The dropSparseCols
and dropSparseRows
functions drop these missing values and return a frame with no missing values.
Functions and values
Function or value | Description |
denseCols(frame)
Signature: frame:Frame<'R,'C> -> ColumnSeries<'R,'C>
Type parameters: 'R, 'C Attributes: [<CompiledName("DenseColumns")>] |
Returns the columns of the data frame that do not have any missing values.
The operation returns a series (indexed by the column keys of the source frame)
containing series representing individual columns of the frame. This is similar
to CompiledName: |
denseRows(frame)
Signature: frame:Frame<'R,'C> -> RowSeries<'R,'C>
Type parameters: 'R, 'C Attributes: [<CompiledName("DenseRows")>] |
Returns the rows of the data frame that do not have any missing values.
The operation returns a series (indexed by the row keys of the source frame)
containing series representing individual row of the frame. This is similar
to CompiledName: |
dropSparseCols(frame)
Signature: frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'R, 'C Attributes: [<CompiledName("DropSparseColumns")>] |
Creates a new data frame that contains only those columns of the original data frame that are dense, meaning that they have a value for each row. The resulting data frame has the same number of rows, but may have fewer columns (or no columns at all). CompiledName: |
dropSparseRows(frame)
Signature: frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'R, 'C Attributes: [<CompiledName("DropSparseRows")>] |
Creates a new data frame that contains only those rows of the original data frame that are dense, meaning that they have a value for each column. The resulting data frame has the same number of columns, but may have fewer rows (or no rows at all). CompiledName: |
dropSparseRowsBy colKey frame
Signature: colKey:'C -> frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'C, 'R Attributes: [<CompiledName("DropSparseRowsBy")>] |
Creates a new data frame that contains only those rows of the original data frame for which the given column has a value (i.e., is not missing). The resulting data frame has the same number of columns, but may have fewer rows (or no rows at all). CompiledName: |
fillMissing direction frame
Signature: direction:Direction -> frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'R, 'C Attributes: [<CompiledName("FillMissing")>] |
Fill missing values in the data frame with the nearest available value (using the specified direction). Note that the frame may still contain missing values after call to this function (e.g. if the first value is not available and we attempt to fill series with previous values). This operation can only be used on ordered frames. Parameters
CompiledName: |
fillMissingUsing f frame
Signature: f:(Series<'R,'T> -> 'R -> 'T) -> frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'R, 'T, 'C Attributes: [<CompiledName("FillMissingUsing")>] |
Fill missing values in the frame using the specified function. The specified function is called with all series and keys for which the frame does not contain value and the result of the call is used in place of the missing value. The operation is only applied to columns (series) that contain values of the
same type as the return type of the provided filling function. The operation
does not attempt to convert between numeric values (so a series containing
Parameters
CompiledName: |
fillMissingWith value frame
Signature: value:'T -> frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'T, 'R, 'C Attributes: [<CompiledName("FillMissingWith")>] |
Fill missing values of a given type in the frame with a constant value.
The operation is only applied to columns (series) that contain values of the
same type as the provided filling value. The operation does not attempt to
convert between numeric values (so a series containing Parameters
CompiledName: |
Processing frames with exceptions
The functions in this group can be used to write computations over frames that may fail.
They use the type tryval<'T>
which is defined as a discriminated union:
1: 2: 3: |
|
Using tryval<'T>
as a value in a data frame is not generally recommended, because
the type of values cannot be tracked in the type. For this reason, it is better to use
tryval<'T>
with individual series. However, tryValues
and fillErrorsWith
functions
can be used to get values, or fill failed values inside an entire data frame.
The tryMapRows
function is more useful. It can be used to write a transformation
that applies a computation (which may fail) to each row of a data frame. The resulting
series is of type Series<'R, tryval<'T>>
and can be processed using the Series
module
functions.
| Success of 'T
| Error of exn
Functions and values
Function or value | Description |
fillErrorsWith value frame
Signature: value:'T -> frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'T, 'R, 'C Attributes: [<CompiledName("FillErrorsWith")>] |
Fills all error cases of a CompiledName: |
tryMapRows f frame
Signature: f:('R -> ObjectSeries<'C> -> 'V) -> frame:Frame<'R,'C> -> Series<'R,'V tryval>
Type parameters: 'R, 'C, 'V Attributes: [<CompiledName("TryMapRows")>] |
Returns a series, obtained by applying the specified projection function CompiledName: |
tryValues(frame)
Signature: frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'R, 'C Attributes: [<CompiledName("TryValues")>] |
Given a data frame containing columns of type CompiledName: |
Sorting and index manipulation
A frame is indexed by row keys and column keys. Both of these indices can be sorted
(by the keys). A frame that is sorted allows a number of additional operations (such
as lookup using the Lookp.ExactOrSmaller
lookup behavior). The functions in this
category provide ways for manipulating the indices. It is expected that most operations
are done on rows and so more functions are available in a row-wise way. A frame can
alwyas be transposed using Frame.transpose
.
Index operations
The existing row/column keys can be replaced by a sequence of new keys using the
indexColsWith
and indexRowsWith
functions. Row keys can also be replaced by
ordinal numbers using indexRowsOrdinally
.
The function indexRows
uses the specified column of the original frame as the
index. It removes the column from the resulting frame (to avoid this, use overloaded
IndexRows
method). This function infers the type of row keys from the context, so it
is usually more convenient to use indexRows[Date|String|Int|...]
functions. Finally,
if you want to calculate the index value based on multiple columns of the row, you
can use indexRowsUsing
.
Sorting frame rows
Frame rows can be sorted according to the value of a specified column using the
sortRows
function; sortRowsBy
takes a projection function which lets you
transform the value of a column (e.g. to project a part of the value).
The functions sortRowsByKey
and sortColsByKey
sort the rows or columns
using the default ordering on the key values. The result is a frame with ordered
index.
Expanding columns
When the frame contains a series with complex .NET objects such as F# records or C# classes, it can be useful to "expand" the column. This operation looks at the type of the objects, gets all properties of the objects (recursively) and generates multiple series representing the properties as columns.
The function expandCols
expands the specified columns while expandAllCols
applies the expansion to all columns of the data frame.
Functions and values
Function or value | Description | ||
expandAllCols nesting frame
Signature: nesting:int -> frame:Frame<'R,string> -> Frame<'R,string>
Type parameters: 'R Attributes: [<CompiledName("ExpandAllColumns")>] |
Creates a new data frame where all columns are expanded based on runtime
structure of the objects they store. The expansion is performed recrusively
to the specified depth. A column can be expanded if it is Parameters
CompiledName: |
||
expandCols names frame
Signature: names:seq<string> -> frame:Frame<'R,string> -> Frame<'R,string>
Type parameters: 'R Attributes: [<CompiledName("ExpandColumns")>] |
Creates a new data frame where the specified columns are expanded based on runtime
structure of the objects they store. A column can be expanded if it is
ExampleGiven a data frame with a series that contains tuples, you can expand the
tuple members and get a frame with columns
Parameters
val df : obj
CompiledName: |
||
indexColsWith keys frame
Signature: keys:seq<'C2> -> frame:Frame<'R,'C1> -> Frame<'R,'C2>
Type parameters: 'C2, 'R, 'C1 Attributes: [<CompiledName("IndexColumnsWith")>] |
Replace the column index of the frame with the provided sequence of column keys. The columns of the frame are assigned keys according to the provided order. The specified column is removed from the resulting frame. Parameters
CompiledName: |
||
indexRows column frame
Signature: column:'C -> frame:Frame<'R1,'C> -> Frame<'R2,'C>
Type parameters: 'C, 'R1, 'R2 Attributes: [<CompiledName("IndexRows")>] |
Returns a data frame whose rows are indexed based on the specified column of the original data frame. The generic type parameter is specifies the type of the values in the required index column (and usually needs to be specified using a type annotation). The specified column is removed from the resulting frame. Parameters
CompiledName: |
||
indexRowsDate column frame
Signature: column:'C -> frame:Frame<'R1,'C> -> Frame<DateTime,'C>
Type parameters: 'C, 'R1 Attributes: [<CompiledName("IndexRowsByDateTime")>] |
Returns a data frame whose rows are indexed based on the specified column of the original
data frame. This function casts (or converts) the column key to values of type Parameters
CompiledName: |
||
indexRowsDateOffs column frame
Signature: column:'C -> frame:Frame<'R1,'C> -> Frame<DateTimeOffset,'C>
Type parameters: 'C, 'R1 Attributes: [<CompiledName("IndexRowsByDateTimeOffset")>] |
Returns a data frame whose rows are indexed based on the specified column of the original
data frame. This function casts (or converts) the column key to values of type Parameters
CompiledName: |
||
indexRowsInt column frame
Signature: column:'C -> frame:Frame<'R1,'C> -> Frame<int,'C>
Type parameters: 'C, 'R1 Attributes: [<CompiledName("IndexRowsByInt")>] |
Returns a data frame whose rows are indexed based on the specified column of the original
data frame. This function casts (or converts) the column key to values of type Parameters
CompiledName: |
||
indexRowsObj column frame
Signature: column:'C -> frame:Frame<'R1,'C> -> Frame<obj,'C>
Type parameters: 'C, 'R1 Attributes: [<CompiledName("IndexRowsByObject")>] |
Returns a data frame whose rows are indexed based on the specified column of the original
data frame. This function casts (or converts) the column key to values of type Parameters
CompiledName: |
||
indexRowsOrdinally(frame)
Signature: frame:Frame<'TRowKey,'TColumnKey> -> Frame<int,'TColumnKey>
Type parameters: 'TRowKey, 'TColumnKey Attributes: [<CompiledName("IndexRowsOrdinally")>] |
Replace the row index of the frame with ordinarilly generated integers starting from zero. The rows of the frame are assigned index according to the current order, or in a non-deterministic way, if the current row index is not ordered. CompiledName: |
||
indexRowsString column frame
Signature: column:'C -> frame:Frame<'R1,'C> -> Frame<string,'C>
Type parameters: 'C, 'R1 Attributes: [<CompiledName("IndexRowsByString")>] |
Returns a data frame whose rows are indexed based on the specified column of the original
data frame. This function casts (or converts) the column key to values of type Parameters
CompiledName: |
||
indexRowsUsing f frame
Signature: f:(ObjectSeries<'C> -> 'R2) -> frame:Frame<'R1,'C> -> Frame<'R2,'C>
Type parameters: 'C, 'R2, 'R1 Attributes: [<CompiledName("IndexRowsUsing")>] |
Replace the row index of the frame with a sequence of row keys generated using a function invoked on each row. Parameters
CompiledName: |
||
indexRowsWith keys frame
Signature: keys:seq<'R2> -> frame:Frame<'R1,'C> -> Frame<'R2,'C>
Type parameters: 'R2, 'R1, 'C Attributes: [<CompiledName("IndexRowsWith")>] |
Replace the row index of the frame with the provided sequence of row keys. The rows of the frame are assigned keys according to the provided order. Parameters
CompiledName: |
||
realignRows keys frame
Signature: keys:seq<'R> -> frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'R, 'C Attributes: [<CompiledName("RealignRows")>] |
Align the existing data to a specified collection of row keys. Values in the data frame that do not match any new key are dropped, new keys (that were not in the original data frame) are assigned missing values. Parameters
CompiledName: |
||
sortColsByKey(frame)
Signature: frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'R, 'C Attributes: [<CompiledName("SortColumnsByKey")>] |
Returns a data frame that contains the same data as the input, but whose columns are an ordered series. This allows using operations that are only available on indexed series such as alignment and inexact lookup. CompiledName: |
||
sortRows colKey frame
Signature: colKey:'C -> frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'C, 'R Attributes: [<CompiledName("SortRows")>] |
Returns a data frame that contains the same data as the input, but whose rows are ordered on a particular column of the frame. CompiledName: |
||
sortRowsBy colKey f frame
Signature: colKey:'C -> f:('T -> 'V) -> frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'C, 'T, 'V, 'R Attributes: [<CompiledName("SortRowBy")>] |
Returns a data frame that contains the same data as the input, but whose rows are ordered on a particular column of the frame. CompiledName: |
||
sortRowsByKey(frame)
Signature: frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'R, 'C Attributes: [<CompiledName("SortRowsByKey")>] |
Returns a data frame that contains the same data as the input, but whose rows are an ordered series. This allows using operations that are only available on indexed series such as alignment and inexact lookup. CompiledName: |
||
sortRowsWith colKey compareFunc frame
Signature: colKey:'C -> compareFunc:('a -> 'a -> int) -> frame:Frame<'R,'C> -> Frame<'R,'C>
Type parameters: 'C, 'a, 'R Attributes: [<CompiledName("SortRowsWith")>] |
Returns a data frame that contains the same data as the input, but whose rows are ordered on a particular column of the frame. CompiledName: |
||
transpose(frame)
Signature: frame:Frame<'R,'TColumnKey> -> Frame<'TColumnKey,'R>
Type parameters: 'R, 'TColumnKey Attributes: [<CompiledName("Transpose")>] |
Returns a transposed data frame. The rows of the original data frame are used as the columns of the new one (and vice versa). Use this operation if you have a data frame and you mostly need to access its rows as a series (because accessing columns as a series is more efficient). CompiledName: |