data-forge
Version:
JavaScript data transformation and analysis toolkit inspired by Pandas and LINQ.
124 lines (123 loc) • 4.69 kB
TypeScript
export { Index, IIndex } from './lib/index';
export { Series, ISeries, SelectorWithIndexFn } from './lib/series';
export { DataFrame, IDataFrame } from './lib/dataframe';
import { Series, ISeries } from '.';
import { DataFrame, IDataFrame } from '.';
/**
* Represents a field from a JavaScript object.
*/
export interface IFieldRecord {
/**
* The name of the field.
*/
Field: string;
/**
* The value of the field.
*/
Value: any;
}
/**
* Convert a regular JavaScript obejct to a dataframe.
* Each row in the dataframe represents a field from the object.
*
* @param obj - The JavaScript object to convert to a dataframe.
*
* @returns Returns a dataframe that lists the fields in the pass-in object.
*/
export declare function fromObject(obj: any): IDataFrame<number, IFieldRecord>;
/**
* Deserialize a dataframe from a JSON text string.
*
* @param jsonTextString The JSON text to deserialize.
*
* @returns Returns a dataframe that has been deserialized from the JSON data.
*/
export declare function fromJSON(jsonTextString: string): IDataFrame<number, any>;
/**
* Deserialize a dataframe from a JSON5 text string.
*
* @param jsonTextString The JSON5 text to deserialize.
*
* @returns Returns a dataframe that has been deserialized from the JSON data.
*/
export declare function fromJSON5(jsonTextString: string): IDataFrame<number, any>;
/**
* Options for parsing CSV data.
*/
export interface ICSVOptions {
/**
* Optionally specifies the column names (when enabled, assumes that the header row is not read from the CSV data).
* Default: undefined
*/
columnNames?: Iterable<string>;
/**
* Automatically pick types based on what the value looks like.
* Default: false.
*/
dynamicTyping?: boolean;
/**
* Skip empty lines in the input.
* Default: true
*/
skipEmptyLines?: boolean;
}
/**
* Deserialize a DataFrame from a CSV text string.
*
* @param csvTextString The CSV text to deserialize.
* @param config Optional configuration options for parsing the CSV data.
* The config object is passed directly to [PapaParse.parse](https://www.papaparse.com/docs#strings), please see [PapaParse docs for additional options](https://www.papaparse.com/docs#config).
*
* @returns Returns a dataframe that has been deserialized from the CSV data.
*/
export declare function fromCSV(csvTextString: string, config?: ICSVOptions): DataFrame<number, any>;
declare const concat: typeof Series.concat;
/**
* Concatenate multiple series into a single series.
* THIS FUNCTION IS DEPRECATED. Instead use dataFrame.Series.concat.
*
* @param {array} series - Array of series to concatenate.
*
* @returns {Series} - Returns the single concatendated series.
*/
export { concat as concatSeries };
declare const zip: typeof Series.zip;
/**
* Zip together multiple series to create a new series.
* THIS FUNCTION IS DEPRECATED. Instead use dataFrame.Series.zip.
*
* @param {array} series - Array of series to zip together.
* @param {function} selector - Selector function that produces a new series based on the input series.
*
* @returns {Series} Returns a single series that is the combination of multiple input series that have been 'zipped' together by the 'selector' function.
*/
export { zip as zipSeries };
/**
* Generate a series from a range of numbers.
*
* @param start - The value of the first number in the range.
* @param count - The number of sequential values in the range.
*
* @returns Returns a series with a sequence of generated values. The series contains 'count' values beginning at 'start'.
*/
export declare function range(start: number, count: number): ISeries<number, number>;
/**
* Replicate a particular value N times to create a series.
*
* @param value The value to replicate.
* @param count The number of times to replicate the value.
*
* @returns Returns a new series that contains N copies of the value.
*/
export declare function replicate<ValueT>(value: ValueT, count: number): ISeries<number, ValueT>;
/**
* Generate a data-frame containing a matrix of values.
*
* @param numColumns - The number of columns in the data-frame.
* @param numRows - The number of rows in the data-frame.
* @param start - The starting value.
* @param increment - The value to increment by for each new value.
*
* @returns Returns a dataframe that contains a matrix of generated values.
*/
export declare function matrix(numColumns: number, numRows: number, start: number, increment: number): IDataFrame<number, any>;