DataFrame.Stack Method

Definition

Namespace: Extreme.DataAnalysis
Assembly: Extreme.Numerics (in Extreme.Numerics.dll) Version: 8.1.23

Overload List

Stack<R>(DataFrame<R, String>, IEnumerable<String>, IEnumerable<String>, String, String) Returns a data frame containing all values in the data frame as row-column-value pairs.
Stack<R, C>(DataFrame<R, C>, Boolean) Transforms a data frame so that the column index is nested into the row index.
Stack<R, C1, C2>(DataFrame<R, ValueTuple<C1, C2>>, Boolean) Transforms a data frame so that the second level of a two-level column index is nested into the row index.
Stack<R1, R2, C>(DataFrame<ValueTuple<R1, R2>, C>, Boolean) Transforms a data frame so that the column index is nested into the row index.

DataFrame.Stack<R, C>(DataFrame<R, C>, Boolean)

Transforms a data frame so that the column index is nested into the row index.
C#
public static DataFrame<(R , C ), long> Stack<R, C>(
	this DataFrame<R, C> frame,
	bool excludeMissing = true
)

Parameters

frame  DataFrame<R, C>
A data frame.
excludeMissing  Boolean  (Optional)
Indicates whether a row should be omitted if the value is missing. The default is true.

Type Parameters

R
The element type of the row index of the data frame.
C
The element type of the column index of the data frame.

Return Value

DataFrame<ValueTuple<R, C>, Int64>
A new data frame whose row index is a hierarchical index where the first level corresponds to the row index of frame, and the second level corresponds to the column index of frame.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type DataFrame<R, C>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

DataFrame.Stack<R, C1, C2>(DataFrame<R, ValueTuple<C1, C2>>, Boolean)

Transforms a data frame so that the second level of a two-level column index is nested into the row index.
C#
public static DataFrame<(R , C2 ), C1> Stack<R, C1, C2>(
	this DataFrame<R, (C1 , C2 )> frame,
	bool excludeMissing
)

Parameters

frame  DataFrame<R, ValueTuple<C1, C2>>
A data frame.
excludeMissing  Boolean
Indicates whether a row should be omitted if the value is missing. The default is true.

Type Parameters

R
The element type of the row index of the data frame.
C1
The element type of the first level of the column index of the data frame.
C2
The element type of the second level of the column index of the data frame.

Return Value

DataFrame<ValueTuple<R, C2>, C1>
A new data frame whose row index is a hierarchical index where the first level corresponds to the row index of frame, and the second level corresponds to the second level of the column index of frame.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type DataFrame<R, ValueTuple<C1, C2>>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

DataFrame.Stack<R1, R2, C>(DataFrame<ValueTuple<R1, R2>, C>, Boolean)

Transforms a data frame so that the column index is nested into the row index.
C#
public static DataFrame<(R1 , R2 , C ), long> Stack<R1, R2, C>(
	this DataFrame<(R1 , R2 ), C> frame,
	bool excludeMissing = true
)

Parameters

frame  DataFrame<ValueTuple<R1, R2>, C>
A data frame.
excludeMissing  Boolean  (Optional)
Indicates whether a row should be omitted if the value is missing. The default is true.

Type Parameters

R1
The element type of the first level of the row index of the data frame.
R2
The element type of the second level of the row index of the data frame.
C
The element type of the column index of the data frame.

Return Value

DataFrame<ValueTuple<R1, R2, C>, Int64>
A new data frame whose row index is a hierarchical index where the first level corresponds to the row index of frame, and the second level corresponds to the column index of frame.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type DataFrame<ValueTuple<R1, R2>, C>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

DataFrame.Stack<R>(DataFrame<R, String>, IEnumerable<String>, IEnumerable<String>, String, String)

Returns a data frame containing all values in the data frame as row-column-value pairs.
C#
public static DataFrame<long, string> Stack<R>(
	this DataFrame<R, string> frame,
	IEnumerable<string> idColumns,
	IEnumerable<string> valueColumns = null,
	string variableKey = "variable",
	string valueKey = "value"
)

Parameters

frame  DataFrame<R, String>
A data frame.
idColumns  IEnumerable<String>
A sequence of keys of the identifier columns, which remain unstacked.
valueColumns  IEnumerable<String>  (Optional)
A sequence of keys of the value columns, which are stacked.
variableKey  String  (Optional)
The key of the value column in the result data frame.
valueKey  String  (Optional)
The key of the value column in the result data frame.

Type Parameters

R
The type of the row index of the data frame.

Return Value

DataFrame<Int64, String>
A data frame with a column corresponding to each key in idColumns, a column for the key of the value columns, and a column for the value of the value columns.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type DataFrame<R, String>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

Missing values are not recorded.

See Also