Deedle


Frame

Namespace: Deedle

Provides static methods for creating frames, reading frame data from CSV files and database (via IDataReader). The type also provides global configuration for reflection-based expansion.

Table of contents

Configuration 

Static members

Static memberDescription
Frame.CustomExpanders
Signature: Dictionary<Type,Func<obj,seq<string * Type * obj>>>

Configures how reflection-based expansion behaves - see also df.ExpandColumns. This (mutable, non-thread-safe) collection lets you specify custom expansion behavior for any type. This is a dictionary with types as keys and functions that implement the expansion as values.

Example

For example, say you have a type MyPair with propreties Item1 of type int and Item2 of type string (and perhaps other properties which makes the default behavior inappropriate). You can register custom expander as:

1: 
2: 
3: 
4: 
Frame.CustomExpanders.Add(typeof<MyPair>, fun v ->
  let a = v :?> MyPair
  [ "First", typeof<int>, box a.Item1;
    "Second", typeof<string>, box a.Item2 ] :> seq<_> )
val typeof<'T> : System.Type
Multiple items
val int : value:'T -> int (requires member op_Explicit)

--------------------
type int = int32

--------------------
type int<'Measure> = int
val box : value:'T -> obj
Multiple items
val string : value:'T -> string

--------------------
type string = System.String
Multiple items
val seq : sequence:seq<'T> -> seq<'T>

--------------------
type seq<'T> = System.Collections.Generic.IEnumerable<'T>

CompiledName: get_CustomExpanders

Frame.NonExpandableInterfaces
Signature: ResizeArray<Type>

Configures how reflection-based expansion behaves - see also df.ExpandColumns. This (mutable, non-thread-safe) collection specifies interfaces whose implementations should not be expanded. By default, this includes collections such as IList.

CompiledName: get_NonExpandableInterfaces

Frame.NonExpandableTypes
Signature: HashSet<Type>

Configures how reflection-based expansion behaves - see also df.ExpandColumns. This (mutable, non-thread-safe) collection specifies additional primitive (but reference) types that should not be expaneded. By default, this includes DateTime, string, etc.

CompiledName: get_NonExpandableTypes

Input and output 

Static members

Static memberDescription
Frame.ReadCsv(...)
Signature: (stream:Stream * hasHeaders:Nullable<bool> * inferTypes:Nullable<bool> * inferRows:Nullable<int> * schema:string * separators:string * culture:string * maxRows:Nullable<int> * missingValues:string [] * preferOptions:Nullable<bool>) -> Frame<int,string>

Load data frame from a CSV file. The operation automatically reads column names from the CSV file (if they are present) and infers the type of values for each column. Columns of primitive types (int, float, etc.) are converted to the right type. Columns of other types (such as dates) are not converted automatically.

Parameters

  • stream - Specifies the input stream, opened at the beginning of CSV data
  • hasHeaders - Specifies whether the input CSV file has header row (when not set, the default value is true)
  • inferTypes - Specifies whether the method should attempt to infer types of columns automatically (set this to false if you want to specify schema)
  • inferRows - If inferTypes=true, this parameter specifies the number of rows to use for type inference. The default value is 100.
  • schema - A string that specifies CSV schema. See the documentation for information about the schema format.
  • separators - A string that specifies one or more (single character) separators that are used to separate columns in the CSV file. Use for example ";" to parse semicolon separated files.
  • culture - Specifies the name of the culture that is used when parsing values in the CSV file (such as "en-US"). The default is invariant culture.
  • maxRows - The maximal number of rows that should be read from the CSV file.
  • missingValues - An array of strings that contains values which should be treated as missing when reading the file. The default value is: "NaN"; "NA"; "#N/A"; ":"; "-"; "TBA"; "TBD".
Frame.ReadCsv(...)
Signature: (location:string * hasHeaders:Nullable<bool> * inferTypes:Nullable<bool> * inferRows:Nullable<int> * schema:string * separators:string * culture:string * maxRows:Nullable<int> * missingValues:string [] * preferOptions:bool) -> Frame<int,string>

Load data frame from a CSV file. The operation automatically reads column names from the CSV file (if they are present) and infers the type of values for each column. Columns of primitive types (int, float, etc.) are converted to the right type. Columns of other types (such as dates) are not converted automatically.

Parameters

  • location - Specifies a file name or an web location of the resource.
  • hasHeaders - Specifies whether the input CSV file has header row (when not set, the default value is true)
  • inferTypes - Specifies whether the method should attempt to infer types of columns automatically (set this to false if you want to specify schema)
  • inferRows - If inferTypes=true, this parameter specifies the number of rows to use for type inference. The default value is 100.
  • schema - A string that specifies CSV schema. See the documentation for information about the schema format.
  • separators - A string that specifies one or more (single character) separators that are used to separate columns in the CSV file. Use for example ";" to parse semicolon separated files.
  • culture - Specifies the name of the culture that is used when parsing values in the CSV file (such as "en-US"). The default is invariant culture.
  • maxRows - Specifies the maximum number of rows that will be read from the CSV file
Frame.ReadReader(reader)
Signature: reader:IDataReader -> Frame<int,string>

Read data from IDataReader. The method reads all rows from the data reader and for each row, gets all the columns. When a value is DBNull, it is treated as missing. The types of created vectors are determined by the field types reported by the data reader.

Other type members 

Static members

Static memberDescription
Frame.CreateEmpty()
Signature: unit -> Frame<'R,'C>
Type parameters: 'R, 'C Attributes:
[<CompilerMessage("This method is not intended for use from F#.", 10001, IsHidden = true, IsError = false)>]
Frame.FromArray2D(array)
Signature: (array:'T [,]) -> Frame<int,int>
Type parameters: 'T Attributes:
[<CompilerMessage("This method is not intended for use from F#.", 10001, IsHidden = true, IsError = false)>]

Create data frame from a 2D array of values. The first dimension of the array is used as rows and the second dimension is treated as columns. Rows and columns of the returned frame are indexed with the element's offset in the array.

Parameters

  • array - A two-dimensional array to be converted into a data frame
Frame.FromColumns(cols)
Signature: cols:Series<'TColKey,Series<'TRowKey,'V>> -> Frame<'TRowKey,'TColKey>
Type parameters: 'TColKey, 'TRowKey, 'V Attributes:
[<CompilerMessage("This method is not intended for use from F#.", 10001, IsHidden = true, IsError = false)>]
Frame.FromColumns(cols)
Signature: cols:Series<'TColKey,ObjectSeries<'TRowKey>> -> Frame<'TRowKey,'TColKey>
Type parameters: 'TColKey, 'TRowKey Attributes:
[<CompilerMessage("This method is not intended for use from F#.", 10001, IsHidden = true, IsError = false)>]
Frame.FromColumns(columns)
Signature: columns:seq<KeyValuePair<'ColKey,ObjectSeries<'RowKey>>> -> Frame<'RowKey,'ColKey>
Type parameters: 'ColKey, 'RowKey Attributes:
[<CompilerMessage("This method is not intended for use from F#.", 10001, IsHidden = true, IsError = false)>]
Frame.FromColumns(columns)
Signature: columns:seq<KeyValuePair<'ColKey,Series<'RowKey,'V>>> -> Frame<'RowKey,'ColKey>
Type parameters: 'ColKey, 'RowKey, 'V Attributes:
[<CompilerMessage("This method is not intended for use from F#.", 10001, IsHidden = true, IsError = false)>]
Frame.FromColumns(cols)
Signature: cols:seq<Series<'ColKey,'V>> -> Frame<'ColKey,int>
Type parameters: 'ColKey, 'V Attributes:
[<CompilerMessage("This method is not intended for use from F#.", 10001, IsHidden = true, IsError = false)>]
Frame.FromRecords(values)
Signature: values:seq<'T> -> Frame<int,string>
Type parameters: 'T Attributes:
[<CompilerMessage("This method is not intended for use from F#.", 10001, IsHidden = true, IsError = false)>]

Creates a data frame from a sequence of any .NET objects. The method uses reflection over the specified type parameter 'T and turns its properties to columns. The rows of the resulting frame are automatically indexed by int.

Example

The method can be nicely used to create a data frame using C# anonymous types (the result is a data frame with columns "A" and "B" containing two rows).

[lang=csharp] var df = Frame.FromRecords(new[] { new { A = 1, B = "Test" }, new { A = 2, B = "Another"} });

Frame.FromRecords(series)
Signature: series:Series<'K,'R> -> Frame<'K,string>
Type parameters: 'K, 'R Attributes:
[<CompilerMessage("This method is not intended for use from F#.", 10001, IsHidden = true, IsError = false)>]

Creates a data frame from a sequence of any .NET objects. The method uses reflection over the specified type parameter 'T and turns its properties to columns.

Frame.FromRowKeys(keys)
Signature: keys:seq<'K> -> Frame<'K,string>
Type parameters: 'K Attributes:
[<CompilerMessage("This method is not intended for use from F#.", 10001, IsHidden = true, IsError = false)>]
Frame.FromRows(rows)
Signature: rows:Series<'TColKey,Series<'TRowKey,'V>> -> Frame<'TColKey,'TRowKey>
Type parameters: 'TColKey, 'TRowKey, 'V Attributes:
[<CompilerMessage("This method is not intended for use from F#.", 10001, IsHidden = true, IsError = false)>]
Frame.FromRows(rows)
Signature: rows:Series<'TColKey,ObjectSeries<'TRowKey>> -> Frame<'TColKey,'TRowKey>
Type parameters: 'TColKey, 'TRowKey Attributes:
[<CompilerMessage("This method is not intended for use from F#.", 10001, IsHidden = true, IsError = false)>]
Frame.FromRows(rows)
Signature: rows:seq<KeyValuePair<'RowKey,ObjectSeries<'ColKey>>> -> Frame<'RowKey,'ColKey>
Type parameters: 'RowKey, 'ColKey Attributes:
[<CompilerMessage("This method is not intended for use from F#.", 10001, IsHidden = true, IsError = false)>]
Frame.FromRows(rows)
Signature: rows:seq<KeyValuePair<'RowKey,Series<'ColKey,'V>>> -> Frame<'RowKey,'ColKey>
Type parameters: 'RowKey, 'ColKey, 'V Attributes:
[<CompilerMessage("This method is not intended for use from F#.", 10001, IsHidden = true, IsError = false)>]
Frame.FromRows(rows)
Signature: rows:seq<Series<'ColKey,'V>> -> Frame<int,'ColKey>
Type parameters: 'ColKey, 'V Attributes:
[<CompilerMessage("This method is not intended for use from F#.", 10001, IsHidden = true, IsError = false)>]
Frame.FromValues(values)
Signature: (values:seq<'?686407 * '?686408 * '?686409>) -> Frame<'?686407,'?686408>
Type parameters: '?686407, '?686408, '?686409 Attributes:
[<CompilerMessage("This method is not intended for use from F#.", 10001, IsHidden = true, IsError = false)>]

Create a data frame from a sequence of tuples containing row key, column key and a value

Frame.FromValues(...)
Signature: (values:seq<'T> * colSel:Func<'T,'C> * rowSel:Func<'T,'R> * valSel:Func<'T,'V>) -> Frame<'R,'C>
Type parameters: 'T, 'C, 'R, 'V Attributes:
[<CompilerMessage("This method is not intended for use from F#.", 10001, IsHidden = true, IsError = false)>]

Create a data frame from a sequence of objects and functions that return row key, column key and value for each object in the input sequence.

Parameters

  • values - Input sequence of objects
  • colSel - A function that returns the column key of an object
  • rowSel - A function that returns the row key of an object
  • valSel - A function that returns the value of an object
Fork me on GitHub