Deedle


FSharpFrameExtensions

Table of contents

Input and output 

Type extensions

Type extensionDescription
frame.SaveCsv(...)
Signature:(stream:Stream * ?includeRowKeys:bool option * ?keyNames:seq<string> option * ?separator:char option * ?culture:CultureInfo option) -> unit

Save data frame to a CSV file or to a Stream. When calling the operation, you can specify whether you want to save the row keys or not (and headers for the keys) and you can also specify the separator (use \t for writing TSV files). When specifying file name ending with .tsv, the \t separator is used automatically.

Parameters

  • stream - Specifies the output stream where the CSV data should be written
  • includeRowKeys - When set to true, the row key is also written to the output file
  • keyNames - Can be used to specify the CSV headers for row key (or keys, for multi-level index)
  • separator - Specify the column separator in the file (the default is \t for TSV files and , for CSV files)
  • culture - Specify the CultureInfo object used for formatting numerical data
frame.SaveCsv(...)
Signature:(path:string * ?includeRowKeys:bool option * ?keyNames:seq<string> option * ?separator:char option * ?culture:CultureInfo option) -> unit

Save data frame to a CSV file or to a Stream. When calling the operation, you can specify whether you want to save the row keys or not (and headers for the keys) and you can also specify the separator (use \t for writing TSV files). When specifying file name ending with .tsv, the \t separator is used automatically.

Parameters

  • path - Specifies the output file name where the CSV data should be written
  • includeRowKeys - When set to true, the row key is also written to the output file
  • keyNames - Can be used to specify the CSV headers for row key (or keys, for multi-level index)
  • separator - Specify the column separator in the file (the default is \t for TSV files and , for CSV files)
  • culture - Specify the CultureInfo object used for formatting numerical data
frame.SaveCsv(path, keyNames)
Signature:(path:string * keyNames:seq<string>) -> unit

Save data frame to a CSV file or to a Stream. When calling the operation, you can specify whether you want to save the row keys or not (and headers for the keys) and you can also specify the separator (use \t for writing TSV files). When specifying file name ending with .tsv, the \t separator is used automatically.

Parameters

  • path - Specifies the output file name where the CSV data should be written
  • keyNames - Specifies the CSV headers for row key (or keys, for multi-level index)
  • separator - Specify the column separator in the file (the default is \t for TSV files and , for CSV files)
  • culture - Specify the CultureInfo object used for formatting numerical data

Other module members 

Functions and values

Function or valueDescription
( $ ) f series
Signature:f:('?9372 -> '?9373) -> series:Series<'?9374,'?9372> -> Series<'?9374,'?9373>
Type parameters: '?9372, '?9373, '?9374

Custom operator that can be used for applying fuction to all elements of a series. This provides a nicer syntactic sugar for the Series.mapValues function. For example:

// Given a float series and a function on floats
let s1 = Series.ofValues [ 1.0 .. 10.0 ]
let adjust v = max 10.0 v

// Apply "adjust (v + v)" to all elements
adjust $ (s1 + s1)
( =?> ) a b
Signature:a:'?9369 -> b:ISeries<'?9370> -> '?9369 * ISeries<'?9370>
Type parameters: '?9369, '?9370
( => ) a b
Signature:a:'?9366 -> b:'?9367 -> '?9366 * '?9367
Type parameters: '?9366, '?9367

Custom operator that can be used when constructing series from observations or frames from key-row or key-column pairs. The operator simply returns a tuple, but it provides a more convenient syntax. For example:

series [ "k1" => 1; "k2" => 15 ]
frame columns
Signature:columns:seq<'?9376 * '?9377> -> Frame<'?9378,'?9376>
Type parameters: '?9376, '?9377, '?9378

A function for constructing data frame from a sequence of name - column pairs. This provides a nicer syntactic sugar for Frame.ofColumns.

Example

To create a simple frame with two columns, you can write:

frame [ "A" => series [ 1 => 30.0; 2 => 35.0 ]
        "B" => series [ 1 => 30.0; 3 => 40.0 ] ]

Type extensions

Type extensionDescription
Frame.ofColumns(cols)
Signature:cols:Series<'?9396,'?9397> -> Frame<'?9398,'?9396>
Type parameters: '?9396, '?9397, '?9398
Frame.ofColumns(cols)
Signature:(cols:seq<'?9400 * '?9401>) -> Frame<'K,'?9400>
Type parameters: '?9400, '?9401, 'K
Frame.ofRecords(series)
Signature:series:Series<'K,'R> -> Frame<'K,string>
Type parameters: 'K, 'R
Frame.ofRecords(values)
Signature:values:seq<'T> -> Frame<int,string>
Type parameters: 'T
Frame.ofRowKeys(keys)
Signature:keys:seq<'?9394> -> Frame<'?9394,string>
Type parameters: '?9394
Frame.ofRows(rows)
Signature:(rows:seq<'?9386 * '?9387>) -> Frame<'?9386,'?9388>
Type parameters: '?9386, '?9387, '?9388
Frame.ofRows(rows)
Signature:rows:Series<'?9390,'?9391> -> Frame<'?9390,'?9392>
Type parameters: '?9390, '?9391, '?9392
Frame.ofRowsOrdinal(rows)
Signature:rows:seq<'?9382> -> Frame<int,'?9383>
Type parameters: '?9382, '?9383, '?9384

Creates a data frame with ordinal Integer index from a sequence of rows. The column indices of individual rows are unioned, so if a row has fewer columns, it will be successfully added, but there will be missing values.

Frame.ofValues(values)
Signature:(values:seq<'?9404 * '?9405 * '?9406>) -> Frame<'?9404,'?9405>
Type parameters: '?9404, '?9405, '?9406
Frame.ReadCsv(...)
Signature:(path:string * ?hasHeaders:bool option * ?inferTypes:bool option * ?inferRows:int option * ?schema:string option * ?separators:string option * ?culture:string option * ?maxRows:int option) -> 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

  • path - Specifies a file name or an web location of the resource.
  • hasHeaders - Specifies whether the input CSV file has header row
  • 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 0, meaninig all rows.
  • 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.
Frame.ReadCsv(...)
Signature:(stream:Stream * ?hasHeaders:bool option * ?inferTypes:bool option * ?inferRows:int option * ?schema:string option * ?separators:string option * ?culture:string option * ?maxRows:int option) -> 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
  • 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 0, meaninig all rows.
  • 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.
frame.ToDataTable(rowKeyNames)
Signature:rowKeyNames:seq<string> -> DataTable
Fork me on GitHub