Data Frame<R, C> Class
Definition
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.4
public class DataFrame<R, C> : IDataFrame,
ISummarizable, IList<DataFrameRow<R, C>>, ICollection<DataFrameRow<R, C>>,
IEnumerable<DataFrameRow<R, C>>, IEnumerable
- Inheritance
- Object → DataFrame<R, C>
- Implements
- IDataFrame, ISummarizable, ICollection<DataFrameRow<R, C>>, IEnumerable<DataFrameRow<R, C>>, IList<DataFrameRow<R, C>>, IEnumerable
Type Parameters
- R
- The element type of the row index.
- C
- The element type of the column index.
Remarks
Use the DataFrame<R, C> type to represent a 2-dimensional collection of possibly heterogeneous data. The rows and columns are indexed by keys of type R and C, respectively. Rows and columns can be accessed through their keys or ordinal position.
Any operation that changes the rows of a data frame always returns a new data frame. Columns can be added and removed from a data frame without creating a new data frame. The values in a column are immutable, so direct modification of data values is not supported.
The columns of a data frame are stored as strongly typed vectors. However, the column types are not part of the type definition of the data frame. This means that the element type of the column must be specified when accessing a column, or an untyped vector is returned as an IVector object. Some care must be taken to specify the correct element type, or an exception may be thrown at runtime.
The fact that the data is stored in columns means that accessing the data is most efficient column-wise. When computing values based on multiple columns, it is better to write the operation in terms of the column vectors than to iterate through the rows of the data frame.
The data frame class supports many data manipulation and transformation operations, including adding and removing columns, selecting rows, structural operations like stacking and creating pivot tables, processing missing values and aggregation. By including the Numerics.NET.DataAnalysis.Linq namespace, LINQ queries are also supported.
Hierarchical row and column indexes are supported. In order to return the proper type of the indexes, some structural operations are defined as extension methods in the static DataFrame class.
Constructors
Data | Constructs a new empty data frame. |
Properties
Column | Gets the number of columns in the data frame. |
Column | Gets or sets the column index of the data frame. |
Columns | Gets an enumerator over the columns of the data frame. |
Item[C] | Gets, sets or adds a column with the specified key. |
Item[Int32] | Gets the column at the specified index. |
Named | Gets an enumerator over pairs of column key values and the corresponding columns. |
Named | Gets an enumerator over pairs of row key values and the corresponding rows. |
Row | Gets the number of rows in the data frame. |
Row | Gets the row index of the data frame. |
Rows | Gets an enumerator over the rows of the data frame. |
Methods
Add | Adds a column to the data frame. |
Add | Adds a column to the data frame. |
Add | Adds a column to the data frame. |
Aggregate<T>(AggregatorGroup<T>) | Applies the specified aggregator to all the columns in the data frame. |
Aggregate<T>(AggregatorGroup<T>[]) | Applies the specified aggregators to all the columns in the data frame. |
Aggregate<T, TResult>(Func<Vector<T>, TResult>) | Applies the specified aggregators to all the columns in the data frame. |
Aggregate<T1, T2, TResult>(Func<Vector<T1>, TResult>, Func<Vector<T2>, TResult>) | Applies the specified aggregators to all the columns in the data frame. |
Aggregate<T1, T2, T3, TResult>(Func<Vector<T1>, TResult>, Func<Vector<T2>, TResult>, Func<Vector<T3>, TResult>) | Applies the specified aggregators to all the columns in the data frame. |
Aggregate | Returns a new data frame that aggregates the columns grouped by the specified column. |
Aggregate | Returns a new data frame that aggregates the columns grouped by the specified column. |
Aggregate | Returns a new data frame that aggregates the columns according to the specified grouping. |
Aggregate | Applies the aggregators from a dictionary to selected columns in the data frame. |
Aggregate | Returns a new data frame that aggregates the columns according to the specified grouping. |
Aggregate | Returns a new data frame that aggregates the columns according to the specified grouping. |
Aggregate | Returns a new data frame that aggregates the columns according to the specified grouping. |
Aggregate | Returns a new data frame that aggregates the columns grouped by the specified vector. |
Aggregate | Returns a new data frame that aggregates the columns grouped by the specified vector. |
Aggregate | Returns a new data frame that aggregates the columns grouped by the specified column. |
Aggregate | Returns a new data frame that aggregates the columns according to the specified grouping. |
Aggregate | Returns a new data frame that aggregates the columns according to the specified grouping. |
Aggregate | Returns a new data frame that aggregates the columns grouped by the specified vector. |
Aggregate | Applies the specified aggregators to all the columns in the data frame. |
Aggregate | Applies the specified aggregation function to the values in each column grouped by the specified grouping column. |
Append( | Combines two data frames by appending the rows of the right data frame to the rows of this data frame. |
Append( | Combines two data frames by appending the rows of the right data frame to the rows of this data frame. |
Apply | Applies a matrix function to this data frame and another and returns the result as a data frame. |
Clone | Makes a copy of the data frame. |
Combine | Combines the data frame with another data frame, aligning the two data frames and using the specified function to generate the value for common values. |
Describe | Returns a data frame containing descriptive statistics for each column in the data frame. |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object) |
Get | Gets the specified column as a Double vector. |
Get | Gets the specified column as a strongly typed vector. |
Get | Returns a new data frame that contains only the specified columns. |
Get | Returns a new data frame that contains only the specified columns. |
Get | Returns a new data frame that contains only the specified columns. |
Get | Returns a new data frame that contains only the specified columns. |
Get | Gets an enumerator for the rows of the data frame. |
Get | Serves as the default hash function. (Inherited from Object) |
Get | Gets the row nearest to the specified row key. |
Get | Gets the row at the specified row index as a vector of the specified type. |
Get | Returns a new data frame that contains only the rows in the specified sequence. |
Get | Gets the row with the specified row key. |
Get | Gets the row at the specified row index as a vector of the specified type. |
Get | Gets the row with the specified row key. |
Get | Gets the row at the specified row index. |
Get | Returns a new data frame that contains only the rows with keys in the specified array. |
Get | Returns a new data frame that contains only the rows in the specified sequence. |
Get | Returns a new data frame that contains only the rows in the specified subset. |
Get | Returns a new data frame that contains only the rows specified by a boolean mask. |
Get | Returns a new data frame that contains only the rows specified by a range. |
Get | Returns a new data frame that contains only the rows in the specified sequence. |
Get | Gets the Type of the current instance. (Inherited from Object) |
Group | Returns a hierarchical index consisting of the current index grouped by the specified column. |
Group | Returns a hierarchical grouping consisting of the current index grouped by the specified grouping values. |
Group | Returns a hierarchical grouping on two columns. |
Grouped | Returns a new data frame by grouping the index by the specified column. |
Head | Returns the first few rows of the data frame. |
Make | Marks the specified column as containing categorical data. |
Make | Marks the specified columns as containing categorical data. |
Make | Marks the specified column as containing categorical data. |
Make | Marks the column at the specified index as containing categorical data. |
Make | Marks the column at the specified index as containing categorical data. |
Map( | Applies the specified function to selected columns and returns the result in a new data frame. |
Map( | Applies the specified function to selected columns and returns the result in a new data frame. |
Map<T>(Func<Vector<T>, IVector>) | Applies the specified function to all columns with the specified element type and returns the result in a new data frame. |
Map<T>(IList<C>, Func<Vector<T>, IVector>, IList<C>) | Applies the specified function to selected columns. |
Map<T>(IList<C>, Func<Vector<T>, IVector>, Func<C, C>) | Applies the specified function to selected columns. |
Map | Applies the specified function to selected columns and appends the results to the end of the data frame. |
Map | Applies the specified function to selected columns and appends the results to the end of the data frame. |
Map | Applies the specified function to selected columns. |
Map | Applies the specified function to selected columns and appends the results to the end of the data frame. |
Map | Applies the specified function to selected columns and appends the results to the end of the data frame. |
Map | Applies the specified function to selected columns. |
Map | Applies the specified function to selected columns. |
Map | Applies the specified function to selected columns and inserts the result after each mapped column in the data frame. |
Map | Applies the specified function to selected columns. |
Map | Applies the specified function to selected columns. |
Map | Applies the specified function to selected columns and inserts the result after each mapped column in the data frame. |
Map | Applies the specified function to selected columns. |
Map | Applies the specified function to selected columns. |
Map | Applies the specified function to selected columns and replaces the columns with the mapped columns. |
Map | Applies the specified function to selected columns. |
Map | Applies the specified function to selected columns. |
Map | Applies the specified function to selected columns and replaces the columns with the mapped columns. |
Map | Applies the specified function to selected columns. |
Memberwise | Creates a shallow copy of the current Object. (Inherited from Object) |
Pivot<R1, C1, T>(C, C, C) | Constructs a new data frame using the specified columns as row and column indexes. |
Pivot<R1, C1, T>(C, C, C, AggregatorGroup<T>) | Constructs a new data frame using the specified columns as row and column indexes and aggregates the values corresponding to each row-column pair. |
Pivot | Returns a two-dimensional grouping on the specified columns. |
Remove | Removes the specified column from the data frame. |
Remove | Removes the column at the specified position from the data frame. |
Remove | Removes the column at the specified position from the data frame. |
Remove | Returns a new data frame with any columns containing missing values removed. |
Remove | Returns a new data frame that has a default numeric row index. The row index is discarded. |
Remove | Returns a new data frame that has a default numeric row index. The row index is moved to a new column in the data frame. |
Remove | Returns a new data frame that has the specified rows removed. |
Remove | Returns a new data frame that has the specified rows removed. |
Remove | Returns a new data frame that has the specified rows removed. |
Remove | Returns a new data frame with any rows containing missing values removed. |
Remove | Returns a new data frame with any rows containing missing values removed. |
Rename | Renames the specified column. |
Rename | Renames the specified column. |
Rename | Renames the columns that satisfy a condition using the specified key generator. |
Replace | Returns a new data frame whose columns have their missing values replaced with the next or previous non-missing value. |
Replace | Returns a new data frame whose columns of the specified type have their missing values replaced with the specified value. |
Replace | Returns a new data frame whose columns of the specified type have their missing values replaced with the corresponding value from a row vector. |
Select | Returns a new data frame that contains the selected rows and uses the specified row index. |
Select | Returns a new data frame that contains the selected rows and uses the specified row index. |
Select | Returns a new data frame that contains the selected rows and uses the specified row index. |
Sort | Sorts the data frame by the specified column. |
Sort | Sorts the data frame by the specified column. |
Sort | Sorts the data frame by the specified column. |
Sort | Sorts the data frame by the specified column. |
Sort | Sorts the data frame by the row index in ascending order. |
Sort | Sorts the data frame by the row index. |
Stack() | Returns a data frame containing all values in the data frame as row-column-value pairs. |
Stack<T>(IEnumerable<C>, IEnumerable<C>, C, C) | Converts a data frame from wide to long format. |
Summarize() | Returns a summary of the contents of the data frame using the default summary options. |
Summarize( | Returns a summary of the contents of the data frame using the specified options. |
Tail | Returns the last few rows of the data frame. |
ToMatrix<T> | Converts the data frame to a matrix with elements of the specified type. |
ToString | Returns a string that represents the current object. (Overrides Object.ToString()) |
Transform | Applies the specified transformation to each column in the data frame. |
Transform | Applies the specified transformation to each element of each column in the data frame. |
Transform | Applies the specified transformation to each column in the data frame. |
Transform | Applies the specified transformation to each column in the data frame. |
Try | Attempts to get the row at the specified row index. |
Unstack<T> | Converts a data frame from long to wide format. |
With | Returns a new data frame that relabels the columns using the specified index. |
With | Returns a new data frame using the specified column as the index. |
With | Returns a new data frame that uses the specified row index. |
With | Returns a new data frame using the specified columns as a hierarchical index. |
With | Returns a new data frame using the specified columns as a hierarchical index. |
Operators
Dynamic( | Gets the specified column as a vector of Double. |
Dynamic | Sets the specified column. |
Extension Methods
Group<DataFrameRow<R, C>> |
Returns a grouping by the unique elements in a list.
(Defined by Grouping) |
Group<DataFrameRow<R, C>> |
Returns a grouping by the unique elements in a sequence.
(Defined by Grouping) |
Group<DataFrameRow<R, C>> |
Returns a grouping by the unique elements in a list
using the specified comparer to determine equality.
(Defined by Grouping) |
Group<DataFrameRow<R, C>> |
Returns a grouping by the unique elements in a sequence
using the specified comparer to determine equality.
(Defined by Grouping) |
Standard |
Returns the standard deviation of the elements of a sequence.
(Defined by Stats) |
Sum<DataFrameRow<R, C>> |
Computes the sum of the sequence of values.
(Defined by ArrayMath) |
Sum<DataFrameRow<R, C>, U> |
Computes the sum of the sequence of values that are obtained
by invoking a transform function on each element of the input sequence.
(Defined by ArrayMath) |
Sum<DataFrameRow<R, C>, T2, U> |
Computes the sum of the sequence of values that are obtained
by invoking a transform function on each pair of elements of
the input sequences.
(Defined by ArrayMath) |