import { IIndex } from './index'; import { IDataFrame } from './dataframe'; /** * Used to configure a series. */ export interface ISeriesConfig { /** * Values to put in the dataframe. * This should be array or iterable of JavaScript values. */ values?: Iterator | Iterable; /*** * The index for the serires. * If omitted the index will default to a 0-based index. */ index?: Iterator | Iterable; /** * Array or iterable of index,value pairs to put in the series. * If index and values are not separately specified they can be extracted * from the pairs. */ pairs?: Iterator<[IndexT, ValueT]> | Iterable<[IndexT, ValueT]>; /*** * Set to true when the series has been baked into memory * and does not need to be lazily evaluated. */ baked?: boolean; } /** * A user-defined callback function that can be applied to each value. */ export declare type CallbackFn = (value: ValueT, index: number) => void; /** * A user-defined selector function. * Transforms a value into another kind of value. */ export declare type SelectorWithIndexFn = (value: FromT, index: number) => ToT; /** * User-defined zipper functions. * Used to 'zip together' multiple series or dataframes. */ export declare type ZipNFn = (input: ISeries) => ReturnT; export declare type Zip2Fn = (a: T1, b: T2) => ReturnT; export declare type Zip3Fn = (a: T1, b: T2, c: T3) => ReturnT; export declare type Zip4Fn = (a: T1, b: T2, c: T3, d: T4) => ReturnT; export declare type Zip5Fn = (a: T1, b: T2, c: T3, d: T4) => ReturnT; /** * A user-defined selector function with no index. * Transforms a value into another kind of value. */ export declare type SelectorFn = (value: FromT) => ToT; /** * A user-defined function that joins two values and produces a result. */ export declare type JoinFn = (a: ValueT1, b: ValueT2) => ResultT; /** * A user-defined predicate function, returns true or false based on input. */ export declare type PredicateFn = (value: ValueT) => boolean; /** * A user-defined function that aggregtates a value into an accumulator * and returns the new result. */ export declare type AggregateFn = (accum: ToT, value: ValueT) => ToT; /** * A user-defined comparer function that Compares to values and * returns true (truthy) if they are equivalent or false (falsy) if not. */ export declare type ComparerFn = (a: ValueT1, b: ValueT2) => boolean; export declare type SeriesConfigFn = () => ISeriesConfig; export declare type GapFillFn = (a: ValueT, b: ValueT) => ResultT[]; /** * Represents the frequency of a type in a series or dataframe. */ export interface ITypeFrequency { /** * The name of the type. */ Type: string; /** * The frequency of the type's appearance in the series or dataframe. */ Frequency: number; } /** * Represents the frequency of a value in a series or dataframe. */ export interface IValueFrequency { /** * The value. */ Value: any; /** * The frequency of the value's appearance in the series or dataframe. */ Frequency: number; } /** * Places a value in a bucket or range of values. * * WARNING: This interface is deprecated and will be removed in the future. */ export interface IBucket { /** * The bucketed value. */ Value: number; /** * The index of the bucket that contains the value. */ Bucket: number; /** * The minimum value in the bucket. */ Min: number; /** * The mid-point value in the bucket. */ Mid: number; /** * The maximum value in the bucket. */ Max: number; } /** * Specifies where from a data window the index is pulled from: the start of the window, the end or from the middle. */ export declare enum WhichIndex { Start = "start", End = "end", } /** * Options to the `Series.frequency` function. */ export interface IFrequencyTableOptions { /** * Lower boundary (if defined). */ lower?: number; /** * Upper boundary (if defined). */ upper?: number; /** * Directly sets the interval (if defined). This is the range of each group. */ interval?: number; /** * Enables capturing of values for each group. */ captureValues?: boolean; } /** * Defines a record in the frequency table output by the `Series.frequency` function. */ export interface IFrequencyTableEntry { /** * Lower value in this group of the frequency table. */ lower?: number; /** * Upper value in this group of the frequency table. */ upper?: number; /** * Count of values in this group. */ count: number; /** * Proportion (0-1) of values in this group. */ proportion: number; /** * Cumulative proportion of values in this and earlier groups. */ cumulative: number; /** * The values that were record in this group. * (if enabled in the options). */ values?: number[]; } /** * Interface that represents a series. * A series contains an indexed sequence of values. * A series indexed by time is a timeseries. * * @typeparam IndexT The type to use for the index. * @typeparam ValueT The type to use for each value. */ export interface ISeries extends Iterable { /** * Get an iterator to enumerate the values of the series. * Enumerating the iterator forces lazy evaluation to complete. * This function is automatically called by `for...of`. * * @return An iterator for the values in the series. * * @example *
     *
     * for (const value of series) {
     *     // ... do something with the value ...
     * }
     * 
*/ [Symbol.iterator](): Iterator; /** * Cast the value of the series to a new type. * This operation has no effect but to retype the values that the series contains. * * @return The same series, but with the type changed. * * @example *
     *
     * const castSeries = series.cast();
     * 
*/ cast(): ISeries; /** * Get the index for the series. * * @return The {@link Index} for the series. * * @example *
     *
     * const index = series.getIndex();
     * 
*/ getIndex(): IIndex; /** * Apply a new {@link Index} to the series. * * @param newIndex The new array or iterable to be the new {@link Index} of the series. Can also be a selector to choose the {@link Index} for each value in the series. * * @return Returns a new series with the specified {@link Index} attached. * * @example *
     *
     * const indexedSeries = series.withIndex([10, 20, 30]);
     * 
* * @example *
     *
     * const indexedSeries = series.withIndex(someOtherSeries);
     * 
* * @example *
     *
     * const indexedSeries = series.withIndex(value => computeIndexFromValue(value));
     * 
* * @example *
     *
     * const indexedSeries = series.withIndex(value => value + 20);
     * 
*/ withIndex(newIndex: Iterable | SelectorFn): ISeries; /** * Resets the {@link Index} of the series back to the default zero-based sequential integer index. * * @return Returns a new series with the {@link Index} reset to the default zero-based index. * * @example *
     *
     * const seriesWithResetIndex = series.resetIndex();
     * 
*/ resetIndex(): ISeries; /** * Merge one or more series into this series. * Values are merged by index. * Values at each index are combined into arrays in the resulting series. * * @param series... One or more other series to merge into the series. * * @returns The merged series. * * @example *
      *
      * const mergedSeries = series1.merge(series2);
      * 
* *
      *
      * const mergedSeries = series1.merge(series2, series3, etc);
      * 
*/ merge(...args: any[]): ISeries; /** * Extract values from the series as an array. * This forces lazy evaluation to complete. * * @return Returns an array of the values contained within the series. * * @example *
    * const values = series.toArray();
    * 
*/ toArray(options?: { includeNulls?: boolean; }): ValueT[]; /** * Retreive the index, values pairs from the series as an array. * Each pair is [index, value]. * This forces lazy evaluation to complete. * * @return Returns an array of pairs that contains the series values. Each pair is a two element array that contains an index and a value. * * @example *
     * const pairs = series.toPairs();
     * 
*/ toPairs(): ([IndexT, ValueT])[]; /** * Convert the series to a JavaScript object. * * @param keySelector User-defined selector function that selects keys for the resulting object. * @param valueSelector User-defined selector function that selects values for the resulting object. * * @return Returns a JavaScript object generated from the series by applying the key and value selector functions. * * @example *
     *
     * const someObject = series.toObject(
     *      value => value, // Specify the value to use for field names in the output object.
     *      value => value // Specify the value to use as the value for each field.
     * );
     * 
*/ toObject(keySelector: (value: ValueT) => KeyT, valueSelector: (value: ValueT) => FieldT): OutT; /** * Transforms an input series, generating a new series. * The transformer function is called for each element of the input and the collection of outputs creates the generated series. * * `select` is an alias for {@link Series.map}. * * This is the same concept as the JavaScript function `Array.map` but maps over a data series rather than an array. * * @param transformer A user-defined transformer function that transforms each element from the input to generate the output. * * @return Returns the series generated by calling the transformer function over each value in the input series. * * @example *
     *
     * function transformer (input) {
     *      const output = // ... construct output from input ...
     *      return output;
     * }
     *
     * const transformed = series.select(transformer);
     * console.log(transformed.toString());
     * 
*/ select(transformer: SelectorWithIndexFn): ISeries; /** * Transforms an input series, generating a new series. * The transformer function is called for each element of the input and the collection of outputs creates the generated series. * * This is the same concept as the JavaScript function `Array.map` but maps over a data series rather than an array. * * @param transformer A user-defined transformer function that transforms each element from the input to generate the output. * * @return Returns a new series generated by calling the transformer function over each element of the input. * * @example *
     *
     * function transformer (input) {
     *      const output = // ... construct output from input ...
     *      return output;
     * }
     *
     * const transformed = series.map(transformer);
     * console.log(transformed.toString());
     * 
*/ map(transformer: SelectorWithIndexFn): ISeries; /** * Transforms and flattens an input series, generating a new series. * The transformer function is called for each value in the input series and produces an array that is then flattened into the generated series. * * `selectMany` is an alias for {@link Series.flatMap}. * * This is the same concept as the JavaScript function `Array.flatMap` but maps over a data series rather than an array. * * @param transformer A user-defined function that transforms each value into an array that is then flattened into the generated series. * * @return Returns a new series generated by calling the transformer function over each element of the input. * * @example *
     *
     * function transformer (input) {
     *      const output = [];
     *      while (someCondition) {
     *          // ... generate zero or more outputs from a single input ...
     *          output.push(... some generated value ...);
     *      }
     *      return output;
     * }
     *
     * const transformed = series.selectMany(transformer);
     * console.log(transformed.toString());
     * 
*/ selectMany(transformer: SelectorWithIndexFn>): ISeries; /** * Transforms and flattens an input series, generating a new series. * The transformer function is called for each value in the input series and produces an array that is then flattened into the generated series. * * This is the same concept as the JavaScript function `Array.flatMap` but maps over a data series rather than an array. * * @param transformer A user-defined function that transforms each value into an array that is then flattened into the generated series. * * @return Returns a new series generated by calling the transformer function over each element of the input. * * @example *
     *
     * function transformer (input) {
     *      const output = [];
     *      while (someCondition) {
     *          // ... generate zero or more outputs from a single input ...
     *          output.push(... some generated value ...);
     *      }
     *      return output;
     * }
     *
     * const transformed = series.flatMap(transformer);
     * console.log(transformed.toString());
     * 
*/ flatMap(transformer: SelectorWithIndexFn>): ISeries; /** * Partition a series into a {@link Series} of *data windows*. * Each value in the new series is a chunk of data from the original series. * * @param period The number of values to include in each data window. * @param whichIndex Sets which side of the window the index comes from: start or end. Can be "start" or "end", defaults to "end". * * @return Returns a new series, each value of which is a chunk (data window) of the original series. * * @example *
     *
     * const windows = series.window(2); // Get values in pairs.
     * const pctIncrease = windows.select(pair => (pair.last() - pair.first()) / pair.first());
     * console.log(pctIncrease.toString());
     * 
* * @example *
     *
     * const salesDf = ... // Daily sales data.
     * const weeklySales = salesDf.window(7); // Partition up into weekly data sets.
     * console.log(weeklySales.toString());
     * 
*/ window(period: number, whichIndex?: WhichIndex): ISeries>; /** * Partition a series into a new series of *rolling data windows*. * Each value in the new series is a rolling chunk of data from the original series. * * @param period The number of data values to include in each data window. * @param whichIndex Sets which side of the window the index comes from: start or end. Can be "start" or "end", defaults to "end". * * @return Returns a new series, each value of which is a rolling chunk of the original series. * * @example *
     *
     * const salesData = ... // Daily sales data.
     * const rollingWeeklySales = salesData.rollingWindow(7); // Get rolling window over weekly sales data.
     * console.log(rollingWeeklySales.toString());
     * 
*/ rollingWindow(period: number, whichIndex?: WhichIndex): ISeries>; /** * Partition a series into a new series of variable-length *data windows* * where the divisions between the data chunks are * defined by a user-provided *comparer* function. * * @param comparer Function that compares two adjacent data values and returns true if they should be in the same window. * * @return Returns a new series, each value of which is a chunk of data from the original series. * * @example *
     *
     * function rowComparer (valueA, valueB) {
     *      if (... valueA should be in the same data window as valueB ...) {
     *          return true;
     *      }
     *      else {
     *          return false;
     *      }
     * };
     *
     * const variableWindows = series.variableWindow(rowComparer);
     */
    variableWindow(comparer: ComparerFn): ISeries>;
    /**
     * Eliminates adjacent duplicate values.
     *
     * For each group of adjacent values that are equivalent only returns the last index/row for the group,
     * thus ajacent equivalent values are collapsed down to the last value.
     *
     * @param selector Optional selector function to determine the value used to compare for equivalence.
     *
     * @return Returns a new series with groups of adjacent duplicate vlaues collapsed to a single value per group.
     *
     * @example
     * 
     *
     * const seriesWithDuplicateRowsRemoved = series.sequentialDistinct(value => value);
     *
     * // Or
     * const seriesWithDuplicateRowsRemoved = series.sequentialDistinct(value => value.someNestedField);
     * 
*/ sequentialDistinct(selector: SelectorFn): ISeries; /** * Reduces the values in the series to a single result. * * `aggregate` is similar to {@link Series.reduce}, but the parameters are reversed. * Please use {@link Series.reduce} in preference to `aggregate`. * * @param seed Optional seed value for producing the aggregation. * @param reducer Function that takes the seed and then each value in the series and produces the reduced value. * * @return Returns a new value that has been reduced from the input series by passing it through the 'reducer' function. * * @example *
     *
     * const dailySales = ... daily sales figures for the past month ...
     * const totalSalesForthisMonth = dailySales.aggregate(
     *      0, // Seed - the starting value.
     *      (accumulator, salesAmount) => accumulator + salesAmount // Aggregation function.
     * );
     * 
* * @example *
     *
     * const previousSales = 500; // We'll seed the aggregation with this value.
     * const dailySales = ... daily sales figures for the past month ...
     * const updatedSales = dailySales.aggregate(
     *      previousSales,
     *      (accumulator, salesAmount) => accumulator + salesAmount
     * );
     * 
* * @example *
     *
     * var salesDataSummary = salesData.aggregate({
     *      TotalSales: series => series.count(),
     *      AveragePrice: series => series.average(),
     *      TotalRevenue: series => series.sum(),
     * });
     * 
*/ aggregate(seedOrSelector: AggregateFn | ToT, selector?: AggregateFn): ToT; /** * Reduces the values in the series to a single result. * * This is the same concept as the JavaScript function `Array.reduce` but reduces a data series rather than an array. * @param reducer Function that takes the seed and then each value in the series and produces the reduced value. * @param seed Optional initial value, if not specifed the first value in the series is used as the initial value. * * @return Returns a new value that has been reduced from the input series by passing it through the 'reducer' function. * * @example *
     *
     * const dailySales = ... daily sales figures for the past month ...
     * const totalSalesForthisMonth = dailySales.reduce(
     *      (accumulator, salesAmount) => accumulator + salesAmount, // Reducer function.
     *      0  // Seed value, the starting value.
     * );
     * 
* * @example *
     *
     * const previousSales = 500; // We'll seed the reduction with this value.
     * const dailySales = ... daily sales figures for the past month ...
     * const updatedSales = dailySales.reduce(
     *      (accumulator, salesAmount) => accumulator + salesAmount,
     *      previousSales
     * );
     * 
*/ reduce(reducer: AggregateFn, seed?: ToT): ToT; /** * Compute the absolute range of values in each period. * The range for each period is the absolute difference between largest (max) and smallest (min) values in that period. * * @param period - Period for computing the range. * @param whichIndex Sets which side of the window the index comes from: start or end. Can be "start" or "end", defaults to "end". * * @returns Returns a new series where each value indicates the absolute range of values for each period in the original series. * * @example *
     *
     * const closingPrice = ... series of closing prices for a particular stock ...
     * const volatility = closingPrice.amountRange(5);
     * 
*/ amountRange(period: number, whichIndex?: WhichIndex): ISeries; /** * Compute the range of values in each period in proportion to the latest value. * The range for each period is the absolute difference between largest (max) and smallest (min) values in that period. * Proportions are expressed as 0-1 values. * * @param period - Period for computing the range. * @param whichIndex Sets which side of the window the index comes from: start or end. Can be "start" or "end", defaults to "end". * * @returns Returns a new series where each value indicates the proportion change from the previous number value in the original series. * * @returns Returns a new series where each value indicates the proportionate range of values for each period in the original series. * * @example *
     *
     * const closingPrice = ... series of closing prices for a particular stock ...
     * const proportionVolatility = closingPrice.proportionRange(5);
     * 
*/ proportionRange(period: number, whichIndex?: WhichIndex): ISeries; /** * Compute the range of values in each period in proportion to the latest value. * The range for each period is the absolute difference between largest (max) and smallest (min) values in that period. * Proportions are expressed as 0-1 values. * * @param period - Period for computing the range. * @param whichIndex Sets which side of the window the index comes from: start or end. Can be "start" or "end", defaults to "end". * * @returns Returns a new series where each value indicates the proportion change from the previous number value in the original series. * * @returns Returns a new series where each value indicates the proportionate range of values for each period in the original series. * * @example *
     *
     * const closingPrice = ... series of closing prices for a particular stock ...
     * const percentVolatility = closingPrice.percentRange(5);
     * 
*/ percentRange(period: number, whichIndex?: WhichIndex): ISeries; /** * Compute the amount of change between pairs or sets of values in the series. * * @param period Optional period for computing the change - defaults to 2. * @param whichIndex Sets which side of the window the index comes from: start or end. Can be "start" or "end", defaults to "end". * * @returns Returns a new series where each value indicates the amount of change from the previous number value in the original series. * * @example *
     *
     * const saleFigures = ... running series of daily sales figures ...
     * const amountChanged = salesFigures.amountChanged(); // Amount that sales has changed, day to day.
     * 
* @example *
     *
     * const saleFigures = ... running series of daily sales figures ...
     * const amountChanged = salesFigures.amountChanged(7); // Amount that sales has changed, week to week.
     * 
*/ amountChange(period?: number, whichIndex?: WhichIndex): ISeries; /** * Compute the proportion change between pairs or sets of values in the series. * Proportions are expressed as 0-1 values. * * @param period Optional period for computing the proportion - defaults to 2. * @param whichIndex Sets which side of the window the index comes from: start or end. Can be "start" or "end", defaults to "end". * * @returns Returns a new series where each value indicates the proportion change from the previous number value in the original series. * * @example *
     *
     * const saleFigures = ... running series of daily sales figures ...
     * const proportionChanged = salesFigures.amountChanged(); // Proportion that sales has changed, day to day.
     * 
* @example *
     *
     * const saleFigures = ... running series of daily sales figures ...
     * const proportionChanged = salesFigures.amountChanged(7); // Proportion that sales has changed, week to week.
     * 
*/ proportionChange(period?: number, whichIndex?: WhichIndex): ISeries; /** * Compute the percentage change between pairs or sets of values in the series. * Percentages are expressed as 0-100 values. * * @param period Optional period for computing the percentage - defaults to 2. * @param whichIndex Sets which side of the window the index comes from: start or end. Can be "start" or "end", defaults to "end". * * @returns Returns a new series where each value indicates the percent change from the previous number value in the original series. * * @example *
     *
     * const saleFigures = ... running series of daily sales figures ...
     * const percentChanged = salesFigures.amountChanged(); // Percent that sales has changed, day to day.
     * 
* @example *
     *
     * const saleFigures = ... running series of daily sales figures ...
     * const percentChanged = salesFigures.amountChanged(7); // Percent that sales has changed, week to week.
     * 
*/ percentChange(period?: number, whichIndex?: WhichIndex): ISeries; /** * For each period, compute the proportion of values that are less than the last value in the period. * Proportions are expressed as 0-1 values. * * @param period Optional period for computing the proportion rank - defaults to 2. * * @returns Returns a new series where each value indicates the proportion rank value for that period. * * @example *
     *
     * const proportionRank = series.proportionRank();
     * 
* @example *
     *
     * const proportionRank = series.proportionRank(100);
     * 
*/ proportionRank(period?: number): ISeries; /** * For each period, compute the percent of values that are less than the last value in the period. * Percent are expressed as 0-100 values. * * @param period Optional period for computing the percent rank - defaults to 2. * * @returns Returns a new series where each value indicates the percent rank value for that period. * * @example *
     *
     * const percentRank = series.percentRank();
     * 
* @example *
     *
     * const percentRank = series.percentRank(100);
     * 
*/ percentRank(period?: number): ISeries; /** * Generates a cumulative sum across a series. * * @returns Returns a new series that is the cumulative sum of values across the input series. */ cumsum(): ISeries; /** * Skip a number of values in the series. * * @param numValues Number of values to skip. * * @return Returns a new series with the specified number of values skipped. * * @example *
     *
     * const seriesWithRowsSkipped = series.skip(10); // Skip 10 rows in the original series.
     * 
*/ skip(numValues: number): ISeries; /** * Skips values in the series while a condition evaluates to true or truthy. * * @param predicate Returns true/truthy to continue to skip values in the original series. * * @return Returns a new series with all initial sequential values removed while the predicate returned true/truthy. * * @example *
     *
     * const seriesWithRowsSkipped = series.skipWhile(salesFigure => salesFigure > 100); // Skip initial sales figure that are less than 100.
     * 
*/ skipWhile(predicate: PredicateFn): ISeries; /** * Skips values in the series untils a condition evaluates to true or truthy. * * @param predicate Return true/truthy to stop skipping values in the original series. * * @return Returns a new series with all initial sequential values removed until the predicate returned true/truthy. * * @example *
     *
     * const seriesWithRowsSkipped = series.skipUntil(salesFigure => salesFigure > 100); // Skip initial sales figures unitl we see one greater than 100.
     * 
*/ skipUntil(predicate: PredicateFn): ISeries; /** * Take a number of values from the series. * * @param numValues Number of values to take. * * @return Returns a new series with only the specified number of values taken from the original series. * * @example *
     *
     * const seriesWithRowsTaken = series.take(15); // Take only the first 15 values from the original series.
     * 
*/ take(numRows: number): ISeries; /** * Takes values from the series while a condition evaluates to true or truthy. * * @param predicate Returns true/truthy to continue to take values from the original series. * * @return Returns a new series with only the initial sequential values that were taken while the predicate returned true/truthy. * * @example *
     *
     * const seriesWithRowsTaken = series.takeWhile(salesFigure => salesFigure > 100); // Take only initial sales figures that are greater than 100.
     * 
*/ takeWhile(predicate: PredicateFn): ISeries; /** * Takes values from the series until a condition evaluates to true or truthy. * * @param predicate Return true/truthy to stop taking values in the original series. * * @return Returns a new series with only the initial sequential values taken until the predicate returned true/truthy. * * @example *
     *
     * const seriesWithRowsTaken = series.takeUntil(salesFigure => salesFigure > 100); // Take all initial sales figures until we see one that is greater than 100.
     * 
*/ takeUntil(predicate: PredicateFn): ISeries; /** * Count the number of values in the seriese * * @return Returns the count of all values. * * @example *
     *
     * const numValues = series.count();
     * 
*/ count(): number; /** * Get the first value of the series. * * @return Returns the first value of the series. * * @example *
     *
     * const firstValue = series.first();
     * 
*/ first(): ValueT; /** * Get the last value of the series. * * @return Returns the last value of the series. * * @example *
     *
     * const lastValue = series.last();
     * 
*/ last(): ValueT; /** * Get the value, if there is one, with the specified index. * * @param index Index to for which to retreive the value. * * @return Returns the value from the specified index in the series or undefined if there is no such index in the present in the series. * * @example *
     *
     * const value = series.at(5); // Get the value at index 5 (with a default 0-based index).
     * 
* * @example *
     *
     * const date = ... some date ...
     * // Retreive the value with specified date from a time-series (assuming date indexed has been applied).
     * const value = series.at(date);
     * 
*/ at(index: IndexT): ValueT | undefined; /** * Get X value from the start of the series. * Pass in a negative value to get all values at the head except for X values at the tail. * * @param numValues Number of values to take. * * @return Returns a new series that has only the specified number of values taken from the start of the original series. * * @examples *
     *
     * const sample = series.head(10); // Take a sample of 10 values from the start of the series.
     * 
*/ head(numValues: number): ISeries; /** * Get X values from the end of the series. * Pass in a negative value to get all values at the tail except X values at the head. * * @param numValues Number of values to take. * * @return Returns a new series that has only the specified number of values taken from the end of the original series. * * @examples *
     *
     * const sample = series.tail(12); // Take a sample of 12 values from the end of the series.
     * 
*/ tail(numValues: number): ISeries; /** * Filter the series using user-defined predicate function. * * `where` is an alias for {@link Series.filter}. * * This is the same concept as the JavaScript function `Array.filter` but filters a data series rather than an array. * * @param predicate Predicate function to filter values from the series. Returns true/truthy to keep elements, or false/falsy to omit elements. * * @return Returns a new series containing only the values from the original series that matched the predicate. * * @example *
     *
     * // Filter so we only have sales figures greater than 100.
     * const filtered = series.where(salesFigure => salesFigure > 100);
     * console.log(filtered.toArray());
     * 
*/ where(predicate: PredicateFn): ISeries; /** * Filter the series through a user-defined predicate function. * * This is the same concept as the JavaScript function `Array.filter` but filters a data series rather than an array. * * @param predicate Predicate function to filter values from the series. Returns true/truthy to keep elements, or false/falsy to omit elements. * * @return Returns a new series containing only the values from the original series that matched the predicate. * * @example *
     *
     * // Filter so we only have sales figures greater than 100.
     * const filtered = series.filter(salesFigure => salesFigure > 100);
     * console.log(filtered.toArray());
     * 
*/ filter(predicate: PredicateFn): ISeries; /** * Invoke a callback function for each value in the series. * * @param callback The calback function to invoke for each value. * * @return Returns the original series with no modifications. * * @example *
     *
     * series.forEach(value => {
     *      // ... do something with the value ...
     * });
     * 
*/ forEach(callback: CallbackFn): ISeries; /** * Evaluates a predicate function for every value in the series to determine * if some condition is true/truthy for **all** values in the series. * * @param predicate Predicate function that receives each value. It should returns true/truthy for a match, otherwise false/falsy. * * @return Returns true if the predicate has returned true or truthy for every value in the series, otherwise returns false. Returns false for an empty series. * * @example *
     *
     * const result = series.all(salesFigure => salesFigure > 100); // Returns true if all sales figures are greater than 100.
     * 
*/ all(predicate: PredicateFn): boolean; /** * Evaluates a predicate function for every value in the series to determine * if some condition is true/truthy for **any** of values in the series. * * If no predicate is specified then it simply checks if the series contains more than zero values. * * @param predicate Optional predicate function that receives each value. It should return true/truthy for a match, otherwise false/falsy. * * @return Returns true if the predicate has returned truthy for any value in the series, otherwise returns false. * If no predicate is passed it returns true if the series contains any values at all. * Returns false for an empty series. * * @example *
     *
     * const result = series.any(salesFigure => salesFigure > 100); // Do we have any sales figures greater than 100?
     * 
* * @example *
     *
     * const result = series.any(); // Do we have any sales figures at all?
     * 
*/ any(predicate?: PredicateFn): boolean; /** * Evaluates a predicate function for every value in the series to determine * if some condition is true/truthy for **none** of values in the series. * * If no predicate is specified then it simply checks if the series contains zero values. * * @param predicate Optional predicate function that receives each value. It should return true/truthy for a match, otherwise false/falsy. * * @return Returns true if the predicate has returned truthy for zero values in the series, otherwise returns false. Returns false for an empty series. * * @example *
     *
     * const result = series.none(salesFigure => salesFigure > 100); // Do we have zero sales figures greater than 100?
     * 
* * @example *
     *
     * const result = series.none(); // Do we have zero sales figures?
     * 
*/ none(predicate?: PredicateFn): boolean; /** * Gets a new series containing all values starting at or after the specified index value. * * @param indexValue The index value at which to start the new series. * * @return Returns a new series containing all values starting at or after the specified index value. * * @example *
     *
     * const series = new Series({
     *      index: [0, 1, 2, 3], // This is the default index.
     *      values: [10, 20, 30, 40],
     * });
     *
     * const lastHalf = series.startAt(2);
     * expect(lastHalf.toArray()).to.eql([30, 40]);
     * 
* * @example *
     *
     * const timeSeries = ... a series indexed by date/time ...
     *
     * // Get all values starting at (or after) a particular date.
     * const result = timeSeries.startAt(new Date(2016, 5, 4));
     * 
*/ startAt(indexValue: IndexT): ISeries; /** * Gets a new series containing all values up until and including the specified index value (inclusive). * * @param indexValue The index value at which to end the new series. * * @return Returns a new series containing all values up until and including the specified index value. * * @example *
     *
     * const series = new Series({
     *      index: [0, 1, 2, 3], // This is the default index.
     *      values: [10, 20, 30, 40],
     * });
     *
     * const firstHalf = series.endAt(1);
     * expect(firstHalf.toArray()).to.eql([10, 20]);
     * 
* * @example *
     *
     * const timeSeries = ... a series indexed by date/time ...
     *
     * // Get all values ending at a particular date.
     * const result = timeSeries.endAt(new Date(2016, 5, 4));
     * 
*/ endAt(indexValue: IndexT): ISeries; /** * Gets a new series containing all values up to the specified index value (exclusive). * * @param indexValue The index value at which to end the new series. * * @return Returns a new series containing all values up to (but not including) the specified index value. * * @example *
     *
     * const series = new Series({
     *      index: [0, 1, 2, 3], // This is the default index.
     *      values: [10, 20, 30, 40],
     * });
     *
     * const firstHalf = series.before(2);
     * expect(firstHalf.toArray()).to.eql([10, 20]);
     * 
* * @example *
     *
     * const timeSeries = ... a series indexed by date/time ...
     *
     * // Get all values before the specified date.
     * const result = timeSeries.before(new Date(2016, 5, 4));
     * 
*/ before(indexValue: IndexT): ISeries; /** * Gets a new series containing all values after the specified index value (exclusive). * * @param indexValue The index value after which to start the new series. * * @return Returns a new series containing all values after the specified index value. * * @example *
     *
     * const series = new Series({
     *      index: [0, 1, 2, 3], // This is the default index.
     *      values: [10, 20, 30, 40],
     * });
     *
     * const lastHalf = df.before(1);
     * expect(lastHalf.toArray()).to.eql([30, 40]);
     * 
* * @example *
     *
     * const timeSerie = ... a series indexed by date/time ...
     *
     * // Get all values after the specified date.
     * const result = timeSeries.after(new Date(2016, 5, 4));
     * 
*/ after(indexValue: IndexT): ISeries; /** * Gets a new series containing all values between the specified index values (inclusive). * * @param startIndexValue The index at which to start the new series. * @param endIndexValue The index at which to end the new series. * * @return Returns a new series containing all values between the specified index values (inclusive). * * @example *
     *
     * const series = new Series({
     *      index: [0, 1, 2, 3, 4, 6], // This is the default index.
     *      values: [10, 20, 30, 40, 50, 60],
     * });
     *
     * const middleSection = series.between(1, 4);
     * expect(middleSection.toArray()).to.eql([20, 30, 40, 50]);
     * 
* * @example *
     *
     * const timeSeries = ... a series indexed by date/time ...
     *
     * // Get all values between the start and end dates (inclusive).
     * const result = timeSeries.after(new Date(2016, 5, 4), new Date(2016, 5, 22));
     * 
*/ between(startIndexValue: IndexT, endIndexValue: IndexT): ISeries; /** * Format the series for display as a string. * This forces lazy evaluation to complete. * * @return Generates and returns a string representation of the series. * * @example *
     *
     * console.log(series.toString());
     * 
*/ toString(): string; /** * Parse a series with string values and convert it to a series with int values. * * @return Returns a new series with values parsed from strings to ints. * * @example *
     *
     * const parsed = series.parseInts();
     * 
*/ parseInts(): ISeries; /** * Parse a series with string values and convert it to a series with float values. * * @return Returns a new series with values parsed from strings to floats. * * @example *
     *
     * const parsed = series.parseFloats();
     * 
*/ parseFloats(): ISeries; /** * Parse a series with string values and convert it to a series with date values. * * @param formatString Optional formatting string for dates. * * Moment is used for date parsing. * https://momentjs.com * * @return Returns a new series with values parsed from strings to dates. * * @example *
     *
     * const parsed = series.parseDates();
     * 
*/ parseDates(formatString?: string): ISeries; /** * Convert a series of values of different types to a series containing string values. * * @param formatString Optional formatting string for dates. * * Numeral.js is used for number formatting. * http://numeraljs.com/ * * Moment is used for date formatting. * https://momentjs.com/docs/#/parsing/string-format/ * * @return Returns a new series values converted from values to strings. * * @example *
     *
     * const result = series.toStrings("YYYY-MM-DD");
     * 
* * @example *
     *
     * const result = series.toStrings("0.00");
     * 
*/ toStrings(formatString?: string): ISeries; /** * Forces lazy evaluation to complete and 'bakes' the series into memory. * * @return Returns a series that has been 'baked', all lazy evaluation has completed. * * @example *
     *
     * const baked = series.bake();
     * 
*/ bake(): ISeries; /** * Converts (inflates) a series to a {@link DataFrame}. * * @param selector Optional user-defined selector function that transforms each value to produce the dataframe. * * @returns Returns a dataframe that was created from the original series. * * @example *
     *
     * const dataframe = series.inflate(); // Inflate a series of objects to a dataframe.
     * 
* * @example *
     *
     * const dataframe = series.inflate(value => { AColumn:  value }); // Produces a dataframe with 1 column from a series of values.
     * 
* * @example *
     *
     * const dataframe = series.inflate(value => { AColumn:  value.NestedValue }); // Extract a nested value and produce a dataframe from it.
     * 
*/ inflate(selector?: SelectorWithIndexFn): IDataFrame; /** * Sum the values in a series and returns the result. * * @returns Returns the sum of the number values in the series. * * @example *
     *
     * const totalSales = salesFigures.sum();
     * 
*/ sum(): number; /** * Average the values in a series and returns the result. * * `average` is an alias of {@link Series.mean}. * * @returns Returns the average of the number values in the series. * * @example *
     *
     * const averageSales = salesFigures.average();
     * 
*/ average(): number; /** * Computes and returns the mean value of a set of values. * * @returns Returns the mean of the number values in the series. * * @example *
     *
     * const averageSales = salesFigures.mean();
     * 
*/ mean(): number; /** * Get the median value in the series. * Note that this sorts the series, which can be expensive. * * @returns Returns the median of the values in the series. * * @example *
     *
     * const medianSales = salesFigures.median();
     * 
*/ median(): number; /** * Get the mode of the values in the series. * The mode is the most frequent value in the series. * Note that this reads the entire series into memory, which can be expensive. * * @returns Returns the mode of the values in the series. * * @example *
     *
     * const modeSales = salesFigures.mode();
     * 
*/ mode(): any; /** * Get the variance of number values in the series. * * @returns Returns the variance of the values in the series. * * @example *
     *
     * const salesVariance = salesFigures.variance();
     * 
*/ variance(): number; /** * Get the standard deviation of number values in the series. * * @returns Returns the standard deviation of the values in the series. * * @example *
     *
     * const salesStdDev = salesFigures.std();
     * 
*/ std(): number; /** * Standardize a series of numbers by converting each "standard deviations from the mean". * This converts the input series to Z scores using the population standard deviation. * * @returns A new series containing Z scores computed from the input series. * * @example *
     *
     * const standardizedSeries = series.standardize();
     * 
*/ standardize(): ISeries; /** * Get the (sample) variance of number values in the series. * * @returns Returns the (sample) variance of the values in the series. * * @example *
     *
     * const salesVariance = salesFigures.variance();
     * 
*/ sampleVariance(): number; /** * Get the (sample) standard deviation of number values in the series. * * @returns Returns the (sample) standard deviation of the values in the series. * * @example *
     *
     * const salesStdDev = salesFigures.sampleStd();
     * 
*/ sampleStd(): number; /** * Standardize a series of numbers by converting each "standard deviations from the mean". * This converts the input series to Z scores using the sample standard deviation. * * @returns A new series containing Z scores computed from the input series. * * @example *
     *
     * const standardizedSeries = series.sampleStandardize();
     * 
*/ sampleStandardize(): ISeries; /** * Get the min value in the series. * * @returns Returns the minimum of the number values in the series. * * @example *
     *
     * const minSales = salesFigures.min();
     * 
*/ min(): number; /** * Get the max value in the series. * * @returns Returns the maximum of the number values in the series. * * @example *
     *
     * const maxSales = salesFigures.max();
     * 
*/ max(): number; /** * Get the range of values in the series. * * @returns Returns the range of the number values in the series. * * @example *
     *
     * const range = salesFigures.range();
     * 
*/ range(): number; /** * Invert the sign of every number value in the series. * This assumes that the input series contains numbers. * * @returns Returns a new series with all number values inverted. * * @example *
     *
     * const inverted = series.invert();
     * 
*/ invert(): ISeries; /** * Counts the number of sequential values where the predicate evaluates to truthy. * Outputs 0 for values when the predicate evaluates to falsy. * * @param predicate User-defined function. Should evaluate to truthy to activate the counter or falsy to deactivate it. * * @returns Returns a new series that counts up the number of sequential values where the predicate evaluates to truthy. 0 values appear when the prediate evaluates to falsy. * * @example *
     *
     * const series = new Series([ 1, 10, 3, 15, 8, 5 ]);
     * const counted = series.counter(value => value >= 3);
     * console.log(counted.toString());
     * 
*/ counter(predicate: PredicateFn): ISeries; /** * Gets a new series in reverse order. * * @return Returns a new series that is the reverse of the original. * * @example *
     *
     * const reversed = series.reverse();
     * 
*/ reverse(): ISeries; /** * Returns only the set of values in the series that are distinct. * Provide a user-defined t (tor to specify criteria for determining the distinctness. * This can be used to remove duplicate values from the series. * * @param selector Optional user-defined selector function that specifies the criteria used to make comparisons for duplicate values. * * @return Returns a series containing only unique values in the series. * * @example *
     *
     * const uniqueValues = series.distinct(); // Get only non-duplicated value in the series.
     * 
* * @example *
     *
     * const bucketedValues = series.distinct(value => Math.floor(value / 10)); // Lump values into buckets of 10.
     * 
*/ distinct(selector?: SelectorFn): ISeries; /** * Collects values in the series into a new series of groups according to a user-defined selector function. * * @param selector User-defined selector function that specifies the criteriay to group by. * * @return Returns a new series of groups. Each group is a series with values that have been grouped by the 'selector' function. * * @example *
     *
     * const sales = ... product sales ...
     * const salesByProduct = sales.groupBy(sale => sale.ProductId);
     * for (const productSalesGroup of salesByProduct) {
     *      // ... do something with each product group ...
     *      const productId = productSalesGroup.first().ProductId;
     *      const totalSalesForProduct = productSalesGroup.deflate(sale => sale.Amount).sum();
     *      console.log(totalSalesForProduct);
     * }
     * 
*/ groupBy(selector: SelectorFn): ISeries>; /** * Collects values in the series into a new series of groups based on if the values are the same or according to a user-defined selector function. * * @param selector Optional selector that specifies the criteria for grouping. * * @return Returns a new series of groups. Each group is a series with values that are the same or have been grouped by the 'selector' function. * * @example *
     *
     * // Some ultra simple stock trading strategy backtesting...
     * const dailyStockPrice = ... daily stock price for a company ...
     * const priceGroups  = dailyStockPrice.groupBy(day => day.close > day.movingAverage);
     * for (const priceGroup of priceGroups) {
     *      // ... do something with each stock price group ...
     *
     *      const firstDay = priceGroup.first();
     *      if (firstDay.close > movingAverage) {
     *          // This group of days has the stock price above its moving average.
     *          // ... maybe enter a long trade here ...
     *      }
     *      else {
     *          // This group of days has the stock price below its moving average.
     *          // ... maybe enter a short trade here ...
     *      }
     * }
     * 
*/ groupSequentialBy(selector?: SelectorFn): ISeries>; /** * Concatenate multiple other series onto this series. * * @param series Multiple arguments. Each can be either a series or an array of series. * * @return Returns a single series concatenated from multiple input series. * * @example *
     *
     * const concatenated = a.concat(b);
     * 
* * @example *
     *
     * const concatenated = a.concat(b, c);
     * 
* * @example *
     *
     * const concatenated = a.concat([b, c]);
     * 
* * @example *
     *
     * const concatenated = a.concat(b, [c, d]);
     * 
* * @example *
     *
     * const otherSeries = [... array of series...];
     * const concatenated = a.concat(otherSeries);
     * 
*/ concat(...series: (ISeries[] | ISeries)[]): ISeries; /** * Zip together multiple series to create a new series. * Preserves the index of the first series. * * @param s2, s3, s4, s4 Multiple series to zip. * @param zipper User-defined zipper function that merges rows. It produces values for the new series based-on values from the input series. * * @return Returns a single series merged from multiple input series. * * @example *
    *
    * const a = new Series([1, 2, 3]);
    * const b = new Series([10, 20, 30]);
    * const zipped = a.zip(b (valueA, valueB) => valueA + valueB);
    * 
*/ zip(s2: ISeries, zipper: Zip2Fn): ISeries; zip(s2: ISeries, s3: ISeries, zipper: Zip3Fn): ISeries; zip(s2: ISeries, s3: ISeries, s4: ISeries, zipper: Zip3Fn): ISeries; zip(...args: any[]): ISeries; /** * Sorts the series in ascending order by a value defined by the user-defined selector function. * * @param selector User-defined selector function that selects the value to sort by. * * @return Returns a new series that has been ordered accorrding to the value chosen by the selector function. * * @example *
     *
     * const orderedSeries = series.orderBy(value => value);
     * 
* * @example *
     *
     * const orderedSeries = series.orderBy(value => value.NestedValue);
     * 
*/ orderBy(selector: SelectorWithIndexFn): IOrderedSeries; /** * Sorts the series in descending order by a value defined by the user-defined selector function. * * @param selector User-defined selector function that selects the value to sort by. * * @return Returns a new series that has been ordered accorrding to the value chosen by the selector function. * * @example *
     *
     * const orderedSeries = series.orderByDescending(value => value);
     * 
* * @example *
     *
     * const orderedSeries = series.orderByDescending(value => value.NestedValue);
     * 
*/ orderByDescending(selector: SelectorWithIndexFn): IOrderedSeries; /** * Creates a new series by merging two input dataframes. * The resulting series contains the union of value from the two input series. * These are the unique combination of values in both series. * This is basically a concatenation and then elimination of duplicates. * * @param other The other series to merge. * @param selector Optional user-defined selector function that selects the value to compare to determine distinctness. * * @return Returns the union of the two series. * * @example *
     *
     * const seriesA = ...
     * const seriesB = ...
     * const merged = seriesA.union(seriesB);
     * 
* * @example *
     *
     * // Merge two sets of customer records that may contain the same
     * // customer record in each set. This is basically a concatenation
     * // of the series and then an elimination of any duplicate records
     * // that result.
     * const customerRecordsA = ...
     * const customerRecordsB = ...
     * const mergedCustomerRecords = customerRecordsA.union(
     *      customerRecordsB,
     *      customerRecord => customerRecord.CustomerId
     * );
     * 
* * * @example *
     *
     * // Note that you can achieve the exact same result as the previous
     * // example by doing a {@link Series.concat) and {@link Series.distinct}
     * // of the input series and then an elimination of any duplicate records
     * // that result.
     * const customerRecordsA = ...
     * const customerRecordsB = ...
     * const mergedCustomerRecords = customerRecordsA
     *      .concat(customerRecordsB)
     *      .distinct(customerRecord => customerRecord.CustomerId);
     * 
* */ union(other: ISeries, selector?: SelectorFn): ISeries; /** * Creates a new series by merging two input series. * The resulting series contains the intersection of values from the two input series. * These are only the values that appear in both series. * * @param inner The inner series to merge (the series you call the function on is the 'outer' series). * @param outerSelector Optional user-defined selector function that selects the key from the outer series that is used to match the two series. * @param innerSelector Optional user-defined selector function that selects the key from the inner series that is used to match the two series. * * @return Returns a new series that contains the intersection of values from the two input series. * * @example *
     *
     * const seriesA = ...
     * const seriesB = ...
     * const mergedDf = seriesA.intersection(seriesB);
     * 
* * @example *
     *
     * // Merge two sets of customer records to find only the
     * // customers that appears in both.
     * const customerRecordsA = ...
     * const customerRecordsB = ...
     * const intersectionOfCustomerRecords = customerRecordsA.intersection(
     *      customerRecordsB,
     *      customerRecord => customerRecord.CustomerId
     * );
     * 
*/ intersection(inner: ISeries, outerSelector?: SelectorFn, innerSelector?: SelectorFn): ISeries; /** * Creates a new series by merging two input series. * The resulting series contains only the values from the 1st series that don't appear in the 2nd series. * This is essentially subtracting the values from the 2nd series from the 1st and creating a new series with the remaining values. * * @param inner The inner series to merge (the series you call the function on is the 'outer' series). * @param outerSelector Optional user-defined selector function that selects the key from the outer series that is used to match the two series. * @param innerSelector Optional user-defined selector function that selects the key from the inner series that is used to match the two series. * * @return Returns a new series that contains only the values from the 1st series that don't appear in the 2nd series. * * @example *
     *
     * const seriesA = ...
     * const seriesB = ...
     * const remainingDf = seriesA.except(seriesB);
     * 
* * @example *
     *
     * // Find the list of customers haven't bought anything recently.
     * const allCustomers = ... list of all customers ...
     * const recentCustomers = ... list of customers who have purchased recently ...
     * const remainingCustomers = allCustomers.except(
     *      recentCustomers,
     *      customerRecord => customerRecord.CustomerId
     * );
     * 
*/ except(inner: ISeries, outerSelector?: SelectorFn, innerSelector?: SelectorFn): ISeries; /** * Creates a new series by merging two input series. * The resulting dataframe contains only those value that have matching keys in both input series. * * @param inner The 'inner' series to join (the series you are callling the function on is the 'outer' series). * @param outerKeySelector User-defined selector function that chooses the join key from the outer series. * @param innerKeySelector User-defined selector function that chooses the join key from the inner series. * @param resultSelector User-defined function that merges outer and inner values. * * @return Returns the new merged series. * * @example *
      *
      * // Join together two sets of customers to find those
      * // that have bought both product A and product B.
      * const customerWhoBoughtProductA = ...
      * const customerWhoBoughtProductB = ...
      * const customersWhoBoughtBothProductsDf = customerWhoBoughtProductA.join(
      *          customerWhoBoughtProductB,
      *          customerA => customerA.CustomerId, // Join key.
      *          customerB => customerB.CustomerId, // Join key.
      *          (customerA, customerB) => {
      *              return {
      *                  // ... merge the results ...
      *              };
      *          }
      *      );
      * 
*/ join(inner: ISeries, outerKeySelector: SelectorFn, innerKeySelector: SelectorFn, resultSelector: JoinFn): ISeries; /** * Creates a new series by merging two input series. * The resulting series contains only those values that are only present in one or the other of the series, not both. * * @param inner The 'inner' series to join (the series you are callling the function on is the 'outer' series). * @param outerKeySelector User-defined selector function that chooses the join key from the outer series. * @param innerKeySelector User-defined selector function that chooses the join key from the inner series. * @param resultSelector User-defined function that merges outer and inner values. * * Implementation from here: * * http://blogs.geniuscode.net/RyanDHatch/?p=116 * * @return Returns the new merged series. * * @example *
     *
     * // Join together two sets of customers to find those
     * // that have bought either product A or product B, not not both.
     * const customerWhoBoughtProductA = ...
     * const customerWhoBoughtProductB = ...
     * const customersWhoBoughtEitherProductButNotBothDf = customerWhoBoughtProductA.joinOuter(
     *          customerWhoBoughtProductB,
     *          customerA => customerA.CustomerId, // Join key.
     *          customerB => customerB.CustomerId, // Join key.
     *          (customerA, customerB) => {
     *              return {
     *                  // ... merge the results ...
     *              };
     *          }
     *      );
     * 
*/ joinOuter(inner: ISeries, outerKeySelector: SelectorFn, innerKeySelector: SelectorFn, resultSelector: JoinFn): ISeries; /** * Creates a new series by merging two input series. * The resulting series contains only those values that are present either in both series or only in the outer (left) series. * * @param inner The 'inner' series to join (the series you are callling the function on is the 'outer' series). * @param outerKeySelector User-defined selector function that chooses the join key from the outer series. * @param innerKeySelector User-defined selector function that chooses the join key from the inner series. * @param resultSelector User-defined function that merges outer and inner values. * * Implementation from here: * * http://blogs.geniuscode.net/RyanDHatch/?p=116 * * @return Returns the new merged series. * * @example *
     *
     * // Join together two sets of customers to find those
     * // that have bought either just product A or both product A and product B.
     * const customerWhoBoughtProductA = ...
     * const customerWhoBoughtProductB = ...
     * const boughtJustAorAandB = customerWhoBoughtProductA.joinOuterLeft(
     *          customerWhoBoughtProductB,
     *          customerA => customerA.CustomerId, // Join key.
     *          customerB => customerB.CustomerId, // Join key.
     *          (customerA, customerB) => {
     *              return {
     *                  // ... merge the results ...
     *              };
     *          }
     *      );
     * 
*/ joinOuterLeft(inner: ISeries, outerKeySelector: SelectorFn, innerKeySelector: SelectorFn, resultSelector: JoinFn): ISeries; /** * Creates a new series by merging two input series. * The resulting series contains only those values that are present either in both series or only in the inner (right) series. * * @param inner The 'inner' series to join (the series you are callling the function on is the 'outer' series). * @param outerKeySelector User-defined selector function that chooses the join key from the outer series. * @param innerKeySelector User-defined selector function that chooses the join key from the inner series. * @param resultSelector User-defined function that merges outer and inner values. * * Implementation from here: * * http://blogs.geniuscode.net/RyanDHatch/?p=116 * * @return Returns the new merged series. * * @example *
     *
     * // Join together two sets of customers to find those
     * // that have bought either just product B or both product A and product B.
     * const customerWhoBoughtProductA = ...
     * const customerWhoBoughtProductB = ...
     * const boughtJustAorAandB = customerWhoBoughtProductA.joinOuterRight(
     *          customerWhoBoughtProductB,
     *          customerA => customerA.CustomerId, // Join key.
     *          customerB => customerB.CustomerId, // Join key.
     *          (customerA, customerB) => {
     *              return {
     *                  // ... merge the results ...
     *              };
     *          }
     *      );
     * 
*/ joinOuterRight(inner: ISeries, outerKeySelector: SelectorFn, innerKeySelector: SelectorFn, resultSelector: JoinFn): ISeries; /** * Produces a new series with all string values truncated to the requested maximum length. * * @param maxLength - The maximum length of the string values after truncation. * * @returns Returns a new series with strings that are truncated to the specified maximum length. * * @example *
     *
     * const truncated = series.truncateStrings(10); // Truncate all string values to max length of 10 characters.
     * 
*/ truncateStrings(maxLength: number): ISeries; /** * Produces a new series with all number values rounded to the specified number of places. * * @param numDecimalPlaces The number of decimal places, defaults to 2. * * @returns Returns a new series with all number values rounded to the specified number of places. * * @example *
     *
     * const series = ... your data series ...
     * const rounded = series.round(); // Round numbers to two decimal places.
     * 
* * @example *
     *
     * const series = ... your data series ...
     * const rounded = series.round(3); // Round numbers to three decimal places.
     * 
*/ round(numDecimalPlaces?: number): ISeries; /** * Insert a pair at the start of the series. * Doesn't modify the original series! The returned series is entirely new and contains values from the original series plus the inserted pair. * * @param pair The index/value pair to insert. * * @return Returns a new series with the specified pair inserted. * * @example *
     *
     * const newIndex = ... index of the new row ...
     * const newRow = ... the new data row to insert ...
     * const insertedSeries = series.insertPair([newIndex, newRows]);
     * 
*/ insertPair(pair: [IndexT, ValueT]): ISeries; /** * Append a pair to the end of a series. * Doesn't modify the original series! The returned series is entirely new and contains values from the original series plus the appended pair. * * @param pair The index/value pair to append. * * @return Returns a new series with the specified pair appended. * * @example *
     *
     * const newIndex = ... index of the new row ...
     * const newRow = ... the new data row to append ...
     * const appendedSeries = series.appendPair([newIndex, newRows]);
     * 
*/ appendPair(pair: [IndexT, ValueT]): ISeries; /** * Removes values from the series by index. */ remove(index: IndexT): ISeries; /** * Fill gaps in a series. * * @param comparer User-defined comparer function that is passed pairA and pairB, two consecutive values, return truthy if there is a gap between the value, or falsey if there is no gap. * @param generator User-defined generator function that is passed pairA and pairB, two consecutive values, returns an array of pairs that fills the gap between the values. * * @return Returns a new series with gaps filled in. * * @example *
     *
     *   var sequenceWithGaps = ...
     *
     *  // Predicate that determines if there is a gap.
     *  var gapExists = (pairA, pairB) => {
     *      // Returns true if there is a gap.
     *      return true;
     *  };
     *
     *  // Generator function that produces new rows to fill the game.
     *  var gapFiller = (pairA, pairB) => {
     *      // Create an array of index, value pairs that fill the gaps between pairA and pairB.
     *      return [
     *          newPair1,
     *          newPair2,
     *          newPair3,
     *      ];
     *  };
     *
     *  var sequenceWithoutGaps = sequenceWithGaps.fillGaps(gapExists, gapFiller);
     * 
*/ fillGaps(comparer: ComparerFn<[IndexT, ValueT], [IndexT, ValueT]>, generator: GapFillFn<[IndexT, ValueT], [IndexT, ValueT]>): ISeries; /** * Returns the specified default series if the input series is empty. * * @param defaultSequence Default series to return if the input series is empty. * * @return Returns 'defaultSequence' if the input series is empty. * * @example *
     *
     * const emptySeries = new Series();
     * const defaultSeries = new Series([ 1, 2, 3 ]);
     * expect(emptyDataFrame.defaultIfEmpty(defaultSeries)).to.eql(defaultSeries);
     * 
* * @example *
     *
     * const nonEmptySeries = new Series([ 100 ]);
     * const defaultSeries = new Series([ 1, 2, 3 ]);
     * expect(nonEmptySeries.defaultIfEmpty(defaultSeries)).to.eql(nonEmptySeries);
     * 
*/ defaultIfEmpty(defaultSequence: ValueT[] | ISeries): ISeries; /** * Detect the the frequency of the types of the values in the series. * This is a good way to understand the shape of your data. * * @return Returns a {@link DataFrame} with rows that confirm to {@link ITypeFrequency} that describes the data types contained in the original series. * * @example *
     *
     * const dataTypes = series.detectTypes();
     * console.log(dataTypes.toString());
     * 
*/ detectTypes(): IDataFrame; /** * Detect the frequency of the values in the series. * This is a good way to understand the shape of your data. * * @return Returns a {@link DataFrame} with rows that conform to {@link IValueFrequency} that describes the values contained in the original series. * * @example *
     *
     * const dataValues = series.detectValues();
     * console.log(dataValues.toString());
     * 
*/ detectValues(): IDataFrame; /** * Organise all values in the series into the specified number of buckets. * Assumes that the series is a series of numbers. * * WARNING: This function is deprecated and will be removed in the future. * * @param numBuckets - The number of buckets to create. * * @returns Returns a dataframe containing bucketed values. The input values are divided up into these buckets. * * @example *
     *
     * const buckets = series.bucket(20); // Distribute values into 20 evenly spaced buckets.
     * console.log(buckets.toString());
     * 
*/ bucket(numBuckets: number): IDataFrame; /** * Counts frequencies in the series to produce a frequency table. * * @param options - Options for computing the frequency table (e.g. `numGroups` which defaults to 10). * * @returns Returns a dataframe for the frequency table showing the frequency for the band of values in each group. * * @example *
     *
     * const series = new Series([ 1, 2, 3, 4 ]);
     * // Or
     * const series = dataFrame.getSeries("SomeColumn");
     *
     * const frequencyTable = series.frequency();
     * console.log(frequencyTable.toArray());
     * 
* @example *
     *
     * const series = new Series([ 37, 63, 56, 54, 39, 49, 55, 114, 59, 55 ]);
     * const frequencyTable = series.frequency({
     *      lower: 40,
     *      upper: 90,
     *      interval: 10,
     * })
     * console.log(frequencyTable.toArray());
     * 
*/ frequency(options?: IFrequencyTableOptions): IDataFrame; } /** * Interface to a series that has been ordered. */ export interface IOrderedSeries extends ISeries { /** * Applys additional sorting (ascending) to an already sorted series. * * @param selector User-defined selector that selects the additional value to sort by. * * @return Returns a new series has been additionally sorted by the value chosen by the selector function. * * @example *
     *
     * // Order sales by salesperson and then by amount (from least to most).
     * const ordered = sales.orderBy(sale => sale.SalesPerson).thenBy(sale => sale.Amount);
     * 
*/ thenBy(selector: SelectorWithIndexFn): IOrderedSeries; /** * Applys additional sorting (descending) to an already sorted series. * * @param selector User-defined selector that selects the additional value to sort by. * * @return Returns a new series has been additionally sorted by the value chosen by the selector function. * * @example *
     *
     * // Order sales by salesperson and then by amount (from most to least).
     * const ordered = sales.orderBy(sale => sale.SalesPerson).thenByDescending(sale => sale.Amount);
     * 
*/ thenByDescending(selector: SelectorWithIndexFn): IOrderedSeries; } /** * Class that represents a series containing a sequence of indexed values. */ export declare class Series implements ISeries { private configFn; private content; private indexedContent; private static readonly defaultCountIterable; private static readonly defaultEmptyIterable; private static initFromIterator(iterator); private static initFromIterable(arr); private static initEmpty(); private static isIterator(input); private static isIterable(input); private static checkIterable(input, fieldName); private static initFromConfig(config); /** * Create a series. * * @param config This can be an array, a configuration object or a function that lazily produces a configuration object. * * It can be an array that specifies the values that the series contains. * * It can be a {@link ISeriesConfig} that defines the values and configuration of the series. * * Or it can be a function that lazily produces a {@link ISeriesConfig}. * * @example *
     *
     * const series = new Series();
     * 
* * @example *
     *
     * const series = new Series([10, 20, 30, 40]);
     * 
* * @example *
     *
     * const series = new Series({ index: [1, 2, 3, 4], values: [10, 20, 30, 40]});
     * 
* * @example *
     *
     * const lazyInit = () => ({ index: [1, 2, 3, 4], values: [10, 20, 30, 40] });
     * const series = new Series(lazyInit);
     * 
*/ constructor(config?: Iterator | Iterable | ISeriesConfig | SeriesConfigFn); private lazyInit(); private getContent(); private getRowByIndex(index); /** * Get an iterator to enumerate the values of the series. * Enumerating the iterator forces lazy evaluation to complete. * This function is automatically called by `for...of`. * * @return An iterator for the series. * * @example *
     *
     * for (const value of series) {
     *     // ... do something with the value ...
     * }
     * 
*/ [Symbol.iterator](): Iterator; /** * Cast the value of the series to a new type. * This operation has no effect but to retype the values that the series contains. * * @return The same series, but with the type changed. * * @example *
     *
     * const castSeries = series.cast();
     * 
*/ cast(): ISeries; /** * Get the index for the series. * * @return The {@link Index} for the series. * * @example *
     *
     * const index = series.getIndex();
     * 
*/ getIndex(): IIndex; /** * Apply a new {@link Index} to the series. * * @param newIndex The new array or iterable to be the new {@link Index} of the series. Can also be a selector to choose the {@link Index} for each value in the series. * * @return Returns a new series with the specified {@link Index} attached. * * @example *
     *
     * const indexedSeries = series.withIndex([10, 20, 30]);
     * 
* * @example *
     *
     * const indexedSeries = series.withIndex(someOtherSeries);
     * 
* * @example *
     *
     * const indexedSeries = series.withIndex(value => computeIndexFromValue(value));
     * 
* * @example *
     *
     * const indexedSeries = series.withIndex(value => value + 20);
     * 
*/ withIndex(newIndex: Iterable | SelectorFn): ISeries; /** * Resets the {@link Index} of the series back to the default zero-based sequential integer index. * * @return Returns a new series with the {@link Index} reset to the default zero-based index. * * @example *
     *
     * const seriesWithResetIndex = series.resetIndex();
     * 
*/ resetIndex(): ISeries; /** * Merge multiple series into a single series. * Values are merged by index. * Values at each index are combined into arrays in the resulting series. * * @param series An array or series of series to merge. * * @returns The merged series. * * @example *
     *
     * const mergedSeries = Series.merge([series1, series2, etc]);
     * 
*/ static merge(series: Iterable>): ISeries; /** * Merge one or more series into this series. * Values are merged by index. * Values at each index are combined into arrays in the resulting series. * * @param series... One or more other series to merge into the series. * * @returns The merged series. * * @example *
      *
      * const mergedSeries = series1.merge(series2);
      * 
* *
      *
      * const mergedSeries = series1.merge(series2, series3, etc);
      * 
*/ merge(...args: any[]): ISeries; /** * Extract values from the series as an array. * This forces lazy evaluation to complete. * * @return Returns an array of the values contained within the series. * * @example *
    * const values = series.toArray();
    * 
*/ toArray(options?: { includeNulls?: boolean; }): any[]; /** * Retreive the index, values pairs from the series as an array. * Each pair is [index, value]. * This forces lazy evaluation to complete. * * @return Returns an array of pairs that contains the series values. Each pair is a two element array that contains an index and a value. * * @example *
     * const pairs = series.toPairs();
     * 
*/ toPairs(): ([IndexT, ValueT])[]; /** * Convert the series to a JavaScript object. * * @param keySelector User-defined selector function that selects keys for the resulting object. * @param valueSelector User-defined selector function that selects values for the resulting object. * * @return Returns a JavaScript object generated from the series by applying the key and value selector functions. * * @example *
     *
     * const someObject = series.toObject(
     *      value => value, // Specify the value to use for field names in the output object.
     *      value => value // Specify the value to use as the value for each field.
     * );
     * 
*/ toObject(keySelector: (value: ValueT) => KeyT, valueSelector: (value: ValueT) => FieldT): OutT; /** * Transforms an input series, generating a new series. * The transformer function is called for each element of the input and the collection of outputs creates the generated series. * * `select` is an alias for {@link Series.map}. * * This is the same concept as the JavaScript function `Array.map` but maps over a data series rather than an array. * * @param transformer A user-defined transformer function that transforms each element from the input to generate the output. * * @return Returns the series generated by calling the transformer function over each value in the input series. * * @example *
     *
     * function transformer (input) {
     *      const output = // ... construct output from input ...
     *      return output;
     * }
     *
     * const transformed = series.select(transformer);
     * console.log(transformed.toString());
     * 
*/ select(transformer: SelectorWithIndexFn): ISeries; /** * Transforms an input series, generating a new series. * The transformer function is called for each element of the input and the collection of outputs creates the generated series. * * This is the same concept as the JavaScript function `Array.map` but maps over a data series rather than an array. * * @param transformer A user-defined transformer function that transforms each element from the input to generate the output. * * @return Returns a new series generated by calling the transformer function over each element of the input. * * @example *
     *
     * function transformer (input) {
     *      const output = // ... construct output from input ...
     *      return output;
     * }
     *
     * const transformed = series.map(transformer);
     * console.log(transformed.toString());
     * 
*/ map(transformer: SelectorWithIndexFn): ISeries; /** * Transforms and flattens an input series, generating a new series. * The transformer function is called for each value in the input series and produces an array that is then flattened into the generated series. * * `selectMany` is an alias for {@link Series.flatMap}. * * This is the same concept as the JavaScript function `Array.flatMap` but maps over a data series rather than an array. * * @param transformer A user-defined function that transforms each value into an array that is then flattened into the generated series. * * @return Returns a new series generated by calling the transformer function over each element of the input. * * @example *
     *
     * function transformer (input) {
     *      const output = [];
     *      while (someCondition) {
     *          // ... generate zero or more outputs from a single input ...
     *          output.push(... some generated value ...);
     *      }
     *      return output;
     * }
     *
     * const transformed = series.selectMany(transformer);
     * console.log(transformed.toString());
     * 
*/ selectMany(transformer: SelectorWithIndexFn>): ISeries; /** * Transforms and flattens an input series, generating a new series. * The transformer function is called for each value in the input series and produces an array that is then flattened into the generated series. * * This is the same concept as the JavaScript function `Array.flatMap` but maps over a data series rather than an array. * * @param transformer A user-defined function that transforms each value into an array that is then flattened into the generated series. * * @return Returns a new series generated by calling the transformer function over each element of the input. * * @example *
     *
     * function transformer (input) {
     *      const output = [];
     *      while (someCondition) {
     *          // ... generate zero or more outputs from a single input ...
     *          output.push(... some generated value ...);
     *      }
     *      return output;
     * }
     *
     * const transformed = series.flatMap(transformer);
     * console.log(transformed.toString());
     * 
*/ flatMap(transformer: SelectorWithIndexFn>): ISeries; /** * Partition a series into a {@link Series} of *data windows*. * Each value in the new series is a chunk of data from the original series. * * @param period The number of values to include in each data window. * @param whichIndex Sets which side of the window the index comes from: start or end. Can be "start" or "end", defaults to "end". * * @return Returns a new series, each value of which is a chunk (data window) of the original series. * * @example *
     *
     * const windows = series.window(2); // Get values in pairs.
     * const pctIncrease = windows.select(pair => (pair.last() - pair.first()) / pair.first());
     * console.log(pctIncrease.toString());
     * 
* * @example *
     *
     * const salesDf = ... // Daily sales data.
     * const weeklySales = salesDf.window(7); // Partition up into weekly data sets.
     * console.log(weeklySales.toString());
     * 
*/ window(period: number, whichIndex?: WhichIndex): ISeries>; /** * Partition a series into a new series of *rolling data windows*. * Each value in the new series is a rolling chunk of data from the original series. * * @param period The number of data values to include in each data window. * @param whichIndex Sets which side of the window the index comes from: start or end. Can be "start" or "end", defaults to "end". * * @return Returns a new series, each value of which is a rolling chunk of the original series. * * @example *
     *
     * const salesData = ... // Daily sales data.
     * const rollingWeeklySales = salesData.rollingWindow(7); // Get rolling window over weekly sales data.
     * console.log(rollingWeeklySales.toString());
     * 
*/ rollingWindow(period: number, whichIndex?: WhichIndex): ISeries>; /** * Partition a series into a new series of variable-length *data windows* * where the divisions between the data chunks are * defined by a user-provided *comparer* function. * * @param comparer Function that compares two adjacent data values and returns true if they should be in the same window. * * @return Returns a new series, each value of which is a chunk of data from the original series. * * @example *
     *
     * function rowComparer (valueA, valueB) {
     *      if (... valueA should be in the same data window as valueB ...) {
     *          return true;
     *      }
     *      else {
     *          return false;
     *      }
     * };
     *
     * const variableWindows = series.variableWindow(rowComparer);
     */
    variableWindow(comparer: ComparerFn): ISeries>;
    /**
     * Eliminates adjacent duplicate values.
     *
     * For each group of adjacent values that are equivalent only returns the last index/row for the group,
     * thus ajacent equivalent values are collapsed down to the last value.
     *
     * @param selector Optional selector function to determine the value used to compare for equivalence.
     *
     * @return Returns a new series with groups of adjacent duplicate vlaues collapsed to a single value per group.
     *
     * @example
     * 
     *
     * const seriesWithDuplicateRowsRemoved = series.sequentialDistinct(value => value);
     *
     * // Or
     * const seriesWithDuplicateRowsRemoved = series.sequentialDistinct(value => value.someNestedField);
     * 
*/ sequentialDistinct(selector?: SelectorFn): ISeries; /** * Reduces the values in the series to a single result. * * `aggregate` is similar to {@link Series.reduce}, but the parameters are reversed. * Please use {@link Series.reduce} in preference to `aggregate`. * * @param seed Optional seed value for producing the aggregation. * @param reducer Function that takes the seed and then each value in the series and produces the reduced value. * * @return Returns a new value that has been reduced from the input series by passing it through the 'reducer' function. * * @example *
     *
     * const dailySales = ... daily sales figures for the past month ...
     * const totalSalesForthisMonth = dailySales.aggregate(
     *      0, // Seed - the starting value.
     *      (accumulator, salesAmount) => accumulator + salesAmount // Aggregation function.
     * );
     * 
* * @example *
     *
     * const previousSales = 500; // We'll seed the aggregation with this value.
     * const dailySales = ... daily sales figures for the past month ...
     * const updatedSales = dailySales.aggregate(
     *      previousSales,
     *      (accumulator, salesAmount) => accumulator + salesAmount
     * );
     * 
* * @example *
     *
     * var salesDataSummary = salesData.aggregate({
     *      TotalSales: series => series.count(),
     *      AveragePrice: series => series.average(),
     *      TotalRevenue: series => series.sum(),
     * });
     * 
*/ aggregate(seedOrSelector: AggregateFn | ToT, selector?: AggregateFn): ToT; /** * Reduces the values in the series to a single result. * * This is the same concept as the JavaScript function `Array.reduce` but reduces a data series rather than an array. * @param reducer Function that takes the seed and then each value in the series and produces the reduced value. * @param seed Optional initial value, if not specifed the first value in the series is used as the initial value. * * @return Returns a value that has been reduced from the input series by passing each element through the reducer function. * * @example *
     *
     * const dailySales = ... daily sales figures for the past month ...
     * const totalSales = dailySales.reduce(
     *      (accumulator, salesAmount) => accumulator + salesAmount, // Reducer function.
     *      0  // Seed value, the starting value.
     * );
     * 
* * @example *
     *
     * const previousSales = 500; // We'll seed the reduction with this value.
     * const dailySales = ... daily sales figures for the past month ...
     * const updatedSales = dailySales.reduce(
     *      (accumulator, salesAmount) => accumulator + salesAmount,
     *      previousSales
     * );
     * 
*/ reduce(reducer: AggregateFn, seed?: ToT): ToT; /** * Compute the absolute range of values in each period. * The range for each period is the absolute difference between largest (max) and smallest (min) values in that period. * * @param period - Period for computing the range. * * @returns Returns a new series where each value indicates the absolute range of values for each period in the original series. * * @example *
     *
     * const closingPrice = ... series of closing prices for a particular stock ...
     * const volatility = closingPrice.amountRange(5);
     * 
*/ amountRange(period: number, whichIndex?: WhichIndex): ISeries; /** * Compute the range of values in each period in proportion to the latest value. * The range for each period is the absolute difference between largest (max) and smallest (min) values in that period. * Proportions are expressed as 0-1 values. * * @param period - Period for computing the range. * * @returns Returns a new series where each value indicates the proportion change from the previous number value in the original series. * * @returns Returns a new series where each value indicates the proportionate range of values for each period in the original series. * * @example *
     *
     * const closingPrice = ... series of closing prices for a particular stock ...
     * const proportionVolatility = closingPrice.proportionRange(5);
     * 
*/ proportionRange(period: number, whichIndex?: WhichIndex): ISeries; /** * Compute the range of values in each period in proportion to the latest value. * The range for each period is the absolute difference between largest (max) and smallest (min) values in that period. * Proportions are expressed as 0-1 values. * * @param period - Period for computing the range. * * @returns Returns a new series where each value indicates the proportion change from the previous number value in the original series. * * @returns Returns a new series where each value indicates the proportionate range of values for each period in the original series. * * @example *
     *
     * const closingPrice = ... series of closing prices for a particular stock ...
     * const percentVolatility = closingPrice.percentRange(5);
     * 
*/ percentRange(period: number, whichIndex?: WhichIndex): ISeries; /** * Compute the amount of change between pairs or sets of values in the series. * * @param period Optional period for computing the change - defaults to 2. * * @returns Returns a new series where each value indicates the amount of change from the previous number value in the original series. * * @example *
     *
     * const saleFigures = ... running series of daily sales figures ...
     * const amountChanged = salesFigures.amountChanged(); // Amount that sales has changed, day to day.
     * 
* @example *
     *
     * const saleFigures = ... running series of daily sales figures ...
     * const amountChanged = salesFigures.amountChanged(7); // Amount that sales has changed, week to week.
     * 
*/ amountChange(period?: number, whichIndex?: WhichIndex): ISeries; /** * Compute the proportion change between pairs or sets of values in the series. * Proportions are expressed as 0-1 values. * * @param period Optional period for computing the proportion - defaults to 2. * * @returns Returns a new series where each value indicates the proportion change from the previous number value in the original series. * * @example *
     *
     * const saleFigures = ... running series of daily sales figures ...
     * const proportionChanged = salesFigures.amountChanged(); // Proportion that sales has changed, day to day.
     * 
* @example *
     *
     * const saleFigures = ... running series of daily sales figures ...
     * const proportionChanged = salesFigures.amountChanged(7); // Proportion that sales has changed, week to week.
     * 
*/ proportionChange(period?: number, whichIndex?: WhichIndex): ISeries; /** * Compute the percentage change between pairs or sets of values in the series. * Percentages are expressed as 0-100 values. * * @param period Optional period for computing the percentage - defaults to 2. * * @returns Returns a new series where each value indicates the percent change from the previous number value in the original series. * * @example *
     *
     * const saleFigures = ... running series of daily sales figures ...
     * const percentChanged = salesFigures.amountChanged(); // Percent that sales has changed, day to day.
     * 
* @example *
     *
     * const saleFigures = ... running series of daily sales figures ...
     * const percentChanged = salesFigures.amountChanged(7); // Percent that sales has changed, week to week.
     * 
*/ percentChange(period?: number, whichIndex?: WhichIndex): ISeries; /** * For each period, compute the proportion of values that are less than the last value in the period. * Proportions are expressed as 0-1 values. * * @param period Optional period for computing the proportion rank - defaults to 2. * * @returns Returns a new series where each value indicates the proportion rank value for that period. * * @example *
     *
     * const proportionRank = series.proportionRank();
     * 
* @example *
     *
     * const proportionRank = series.proportionRank(100);
     * 
*/ proportionRank(period?: number): ISeries; /** * For each period, compute the percent of values that are less than the last value in the period. * Percent are expressed as 0-100 values. * * @param period Optional period for computing the percent rank - defaults to 2. * * @returns Returns a new series where each value indicates the percent rank value for that period. * * @example *
     *
     * const percentRank = series.percentRank();
     * 
* @example *
     *
     * const percentRank = series.percentRank(100);
     * 
*/ percentRank(period?: number): ISeries; /** * Generates a cumulative sum across a series. * * @returns Returns a new series that is the cumulative sum of values across the input series. */ cumsum(): ISeries; /** * Skip a number of values in the series. * * @param numValues Number of values to skip. * * @return Returns a new series with the specified number of values skipped. * * @example *
     *
     * const seriesWithRowsSkipped = series.skip(10); // Skip 10 rows in the original series.
     * 
*/ skip(numValues: number): ISeries; /** * Skips values in the series while a condition evaluates to true or truthy. * * @param predicate Returns true/truthy to continue to skip values in the original series. * * @return Returns a new series with all initial sequential values removed while the predicate returned true/truthy. * * @example *
     *
     * const seriesWithRowsSkipped = series.skipWhile(salesFigure => salesFigure > 100); // Skip initial sales figure that are less than 100.
     * 
*/ skipWhile(predicate: PredicateFn): ISeries; /** * Skips values in the series untils a condition evaluates to true or truthy. * * @param predicate Return true/truthy to stop skipping values in the original series. * * @return Returns a new series with all initial sequential values removed until the predicate returned true/truthy. * * @example *
     *
     * const seriesWithRowsSkipped = series.skipUntil(salesFigure => salesFigure > 100); // Skip initial sales figures unitl we see one greater than 100.
     * 
*/ skipUntil(predicate: PredicateFn): ISeries; /** * Take a number of values from the series. * * @param numValues Number of values to take. * * @return Returns a new series with only the specified number of values taken from the original series. * * @example *
     *
     * const seriesWithRowsTaken = series.take(15); // Take only the first 15 values from the original series.
     * 
*/ take(numRows: number): ISeries; /** * Takes values from the series while a condition evaluates to true or truthy. * * @param predicate Returns true/truthy to continue to take values from the original series. * * @return Returns a new series with only the initial sequential values that were taken while the predicate returned true/truthy. * * @example *
     *
     * const seriesWithRowsTaken = series.takeWhile(salesFigure => salesFigure > 100); // Take only initial sales figures that are greater than 100.
     * 
*/ takeWhile(predicate: PredicateFn): ISeries; /** * Takes values from the series until a condition evaluates to true or truthy. * * @param predicate Return true/truthy to stop taking values in the original series. * * @return Returns a new series with only the initial sequential values taken until the predicate returned true/truthy. * * @example *
     *
     * const seriesWithRowsTaken = series.takeUntil(salesFigure => salesFigure > 100); // Take all initial sales figures until we see one that is greater than 100.
     * 
*/ takeUntil(predicate: PredicateFn): ISeries; /** * Static version of the count function for use with {@link DataFrame.summarize} and {@link DataFrame.pivot} functions. * * @param series Input series to be counted. * * @returns Returns the count of values in the series. * * @example *
     *
     * const summary = dataFrame.summarize({
     *      ColumnToBeCounted: Series.count,
     * });
     * 
*/ static count(series: ISeries): number; /** * Count the number of values in the series. * * @return Returns the count of all values. * * @example *
     *
     * const numValues = series.count();
     * 
*/ count(): number; /** * Get the first value of the series. * * @return Returns the first value of the series. * * @example *
     *
     * const firstValue = series.first();
     * 
*/ first(): ValueT; /** * Get the last value of the series. * * @return Returns the last value of the series. * * @example *
     *
     * const lastValue = series.last();
     * 
*/ last(): ValueT; /** * Get the value, if there is one, with the specified index. * * @param index Index to for which to retreive the value. * * @return Returns the value from the specified index in the series or undefined if there is no such index in the present in the series. * * @example *
     *
     * const value = series.at(5); // Get the value at index 5 (with a default 0-based index).
     * 
* * @example *
     *
     * const date = ... some date ...
     * // Retreive the value with specified date from a time-series (assuming date indexed has been applied).
     * const value = series.at(date);
     * 
*/ at(index: IndexT): ValueT | undefined; /** * Get X value from the start of the series. * Pass in a negative value to get all values at the head except for X values at the tail. * * @param numValues Number of values to take. * * @return Returns a new series that has only the specified number of values taken from the start of the original series. * * @examples *
     *
     * const sample = series.head(10); // Take a sample of 10 values from the start of the series.
     * 
*/ head(numValues: number): ISeries; /** * Get X values from the end of the series. * Pass in a negative value to get all values at the tail except X values at the head. * * @param numValues Number of values to take. * * @return Returns a new series that has only the specified number of values taken from the end of the original series. * * @examples *
     *
     * const sample = series.tail(12); // Take a sample of 12 values from the end of the series.
     * 
*/ tail(numValues: number): ISeries; /** * Filter the series through a user-defined predicate function. * * `where` is an alias for {@link Series.filter}. * * This is the same concept as the JavaScript function `Array.filter` but filters a data series rather than an array. * * @param predicate Predicate function to filter values from the series. Returns true/truthy to keep elements, or false/falsy to omit elements. * * @return Returns a new series containing only the values from the original series that matched the predicate. * * @example *
     *
     * // Filter so we only have sales figures greater than 100.
     * const filtered = series.where(salesFigure => salesFigure > 100);
     * console.log(filtered.toArray());
     * 
*/ where(predicate: PredicateFn): ISeries; /** * Filter the series through a user-defined predicate function. * * This is the same concept as the JavaScript function `Array.filter` but filters a data series rather than an array. * * @param predicate Predicate function to filter values from the series. Returns true/truthy to keep elements, or false/falsy to omit elements. * * @return Returns a new series containing only the values from the original series that matched the predicate. * * @example *
     *
     * // Filter so we only have sales figures greater than 100.
     * const filtered = series.filter(salesFigure => salesFigure > 100);
     * console.log(filtered.toArray());
     * 
*/ filter(predicate: PredicateFn): ISeries; /** * Invoke a callback function for each value in the series. * * @param callback The calback function to invoke for each value. * * @return Returns the original series with no modifications. * * @example *
     *
     * series.forEach(value => {
     *      // ... do something with the value ...
     * });
     * 
*/ forEach(callback: CallbackFn): ISeries; /** * Evaluates a predicate function for every value in the series to determine * if some condition is true/truthy for **all** values in the series. * * @param predicate Predicate function that receives each value. It should returns true/truthy for a match, otherwise false/falsy. * * @return Returns true if the predicate has returned true or truthy for every value in the series, otherwise returns false. Returns false for an empty series. * * @example *
     *
     * const result = series.all(salesFigure => salesFigure > 100); // Returns true if all sales figures are greater than 100.
     * 
*/ all(predicate: PredicateFn): boolean; /** * Evaluates a predicate function for every value in the series to determine * if some condition is true/truthy for **any** of values in the series. * * If no predicate is specified then it simply checks if the series contains more than zero values. * * @param predicate Optional predicate function that receives each value. It should return true/truthy for a match, otherwise false/falsy. * * @return Returns true if the predicate has returned truthy for any value in the series, otherwise returns false. * If no predicate is passed it returns true if the series contains any values at all. * Returns false for an empty series. * * @example *
     *
     * const result = series.any(salesFigure => salesFigure > 100); // Do we have any sales figures greater than 100?
     * 
* * @example *
     *
     * const result = series.any(); // Do we have any sales figures at all?
     * 
*/ any(predicate?: PredicateFn): boolean; /** * Evaluates a predicate function for every value in the series to determine * if some condition is true/truthy for **none** of values in the series. * * If no predicate is specified then it simply checks if the series contains zero values. * * @param predicate Optional predicate function that receives each value. It should return true/truthy for a match, otherwise false/falsy. * * @return Returns true if the predicate has returned truthy for zero values in the series, otherwise returns false. Returns false for an empty series. * * @example *
     *
     * const result = series.none(salesFigure => salesFigure > 100); // Do we have zero sales figures greater than 100?
     * 
* * @example *
     *
     * const result = series.none(); // Do we have zero sales figures?
     * 
*/ none(predicate?: PredicateFn): boolean; /** * Gets a new series containing all values starting at or after the specified index value. * * @param indexValue The index value at which to start the new series. * * @return Returns a new series containing all values starting at or after the specified index value. * * @example *
     *
     * const series = new Series({
     *      index: [0, 1, 2, 3], // This is the default index.
     *      values: [10, 20, 30, 40],
     * });
     *
     * const lastHalf = series.startAt(2);
     * expect(lastHalf.toArray()).to.eql([30, 40]);
     * 
* * @example *
     *
     * const timeSeries = ... a series indexed by date/time ...
     *
     * // Get all values starting at (or after) a particular date.
     * const result = timeSeries.startAt(new Date(2016, 5, 4));
     * 
*/ startAt(indexValue: IndexT): ISeries; /** * Gets a new series containing all values up until and including the specified index value (inclusive). * * @param indexValue The index value at which to end the new series. * * @return Returns a new series containing all values up until and including the specified index value. * * @example *
     *
     * const series = new Series({
     *      index: [0, 1, 2, 3], // This is the default index.
     *      values: [10, 20, 30, 40],
     * });
     *
     * const firstHalf = series.endAt(1);
     * expect(firstHalf.toArray()).to.eql([10, 20]);
     * 
* * @example *
     *
     * const timeSeries = ... a series indexed by date/time ...
     *
     * // Get all values ending at a particular date.
     * const result = timeSeries.endAt(new Date(2016, 5, 4));
     * 
*/ endAt(indexValue: IndexT): ISeries; /** * Gets a new series containing all values up to the specified index value (exclusive). * * @param indexValue The index value at which to end the new series. * * @return Returns a new series containing all values up to (but not including) the specified index value. * * @example *
     *
     * const series = new Series({
     *      index: [0, 1, 2, 3], // This is the default index.
     *      values: [10, 20, 30, 40],
     * });
     *
     * const firstHalf = series.before(2);
     * expect(firstHalf.toArray()).to.eql([10, 20]);
     * 
* * @example *
     *
     * const timeSeries = ... a series indexed by date/time ...
     *
     * // Get all values before the specified date.
     * const result = timeSeries.before(new Date(2016, 5, 4));
     * 
*/ before(indexValue: IndexT): ISeries; /** * Gets a new series containing all values after the specified index value (exclusive). * * @param indexValue The index value after which to start the new series. * * @return Returns a new series containing all values after the specified index value. * * @example *
     *
     * const series = new Series({
     *      index: [0, 1, 2, 3], // This is the default index.
     *      values: [10, 20, 30, 40],
     * });
     *
     * const lastHalf = df.before(1);
     * expect(lastHalf.toArray()).to.eql([30, 40]);
     * 
* * @example *
     *
     * const timeSerie = ... a series indexed by date/time ...
     *
     * // Get all values after the specified date.
     * const result = timeSeries.after(new Date(2016, 5, 4));
     * 
*/ after(indexValue: IndexT): ISeries; /** * Gets a new series containing all values between the specified index values (inclusive). * * @param startIndexValue The index at which to start the new series. * @param endIndexValue The index at which to end the new series. * * @return Returns a new series containing all values between the specified index values (inclusive). * * @example *
     *
     * const series = new Series({
     *      index: [0, 1, 2, 3, 4, 6], // This is the default index.
     *      values: [10, 20, 30, 40, 50, 60],
     * });
     *
     * const middleSection = series.between(1, 4);
     * expect(middleSection.toArray()).to.eql([20, 30, 40, 50]);
     * 
* * @example *
     *
     * const timeSeries = ... a series indexed by date/time ...
     *
     * // Get all values between the start and end dates (inclusive).
     * const result = timeSeries.after(new Date(2016, 5, 4), new Date(2016, 5, 22));
     * 
*/ between(startIndexValue: IndexT, endIndexValue: IndexT): ISeries; /** * Format the series for display as a string. * This forces lazy evaluation to complete. * * @return Generates and returns a string representation of the series. * * @example *
     *
     * console.log(series.toString());
     * 
*/ toString(): string; static parseInt(value: any | undefined | null, valueIndex: number): number | undefined; /** * Parse a series with string values and convert it to a series with int values. * * @return Returns a new series with values parsed from strings to ints. * * @example *
     *
     * const parsed = series.parseInts();
     * 
*/ parseInts(): ISeries; static parseFloat(value: any | undefined | null, valueIndex: number): number | undefined; /** * Parse a series with string values and convert it to a series with float values. * * @return Returns a new series with values parsed from strings to floats. * * @example *
     *
     * const parsed = series.parseFloats();
     * 
*/ parseFloats(): ISeries; static parseDate(value: any | undefined | null, valueIndex: number, formatString?: string): Date | undefined; /** * Parse a series with string values and convert it to a series with date values. * * @param formatString Optional formatting string for dates. * * Moment is used for date parsing. * https://momentjs.com * * @return Returns a new series with values parsed from strings to dates. * * @example *
     *
     * const parsed = series.parseDates();
     * 
*/ parseDates(formatString?: string): ISeries; static toString(value: any | undefined | null, formatString?: string): string | undefined | null; /** * Convert a series of values of different types to a series containing string values. * * @param formatString Optional formatting string for dates. * * Numeral.js is used for number formatting. * http://numeraljs.com/ * * Moment is used for date formatting. * https://momentjs.com/docs/#/parsing/string-format/ * * @return Returns a new series values converted from values to strings. * * @example *
     *
     * const result = series.toStrings("YYYY-MM-DD");
     * 
* * @example *
     *
     * const result = series.toStrings("0.00");
     * 
*/ toStrings(formatString?: string): ISeries; /** * Forces lazy evaluation to complete and 'bakes' the series into memory. * * @return Returns a series that has been 'baked', all lazy evaluation has completed. * * @example *
     *
     * const baked = series.bake();
     * 
*/ bake(): ISeries; /** * Converts (inflates) a series to a {@link DataFrame}. * * @param selector Optional user-defined selector function that transforms each value to produce the dataframe. * * @returns Returns a dataframe that was created from the original series. * * @example *
     *
     * const dataframe = series.inflate(); // Inflate a series of objects to a dataframe.
     * 
* * @example *
     *
     * const dataframe = series.inflate(value => { AColumn:  value }); // Produces a dataframe with 1 column from a series of values.
     * 
* * @example *
     *
     * const dataframe = series.inflate(value => { AColumn:  value.NestedValue }); // Extract a nested value and produce a dataframe from it.
     * 
*/ inflate(selector?: SelectorWithIndexFn): IDataFrame; private asNumberSeries(); /** * Static version of the sum function for use with {@link DataFrame.summarize} and {@link DataFrame.pivot} functions. * * @param series Input series to be summed. * * @returns Returns the sum of the number values in the series. * * @example *
     *
     * const summary = dataFrame.summarize({
     *      ColumnToBeSummed: Series.sum,
     * });
     * 
*/ static sum(series: ISeries): number; /** * Sum the values in a series and returns the result. * * @returns Returns the sum of the number values in the series. * * @example *
     *
     * const totalSales = salesFigures.sum();
     * 
*/ sum(): number; /** * Static version of the average function for use with {@link DataFrame.summarize} and {@link DataFrame.pivot} functions. * * @param series Input series to be averaged. * * @returns Returns the average of the number values in the series. * * @example *
     *
     * const summary = dataFrame.summarize({
     *      ColumnToBeAveraged: Series.average,
     * });
     * 
*/ static average(series: ISeries): number; /** * Average the values in a series and returns the result * * `average` is an alias of {@link Series.mean}. * * @returns Returns the average of the number values in the series. * * @example *
     *
     * const averageSales = salesFigures.average();
     * 
*/ average(): number; /** * Static version of the mean function for use with {@link DataFrame.summarize} and {@link DataFrame.pivot} functions. * * @param series Input series for which to compute the mean. * * @returns Returns the mean of the number values in the series. * * @example *
     *
     * const summary = dataFrame.summarize({
     *      ColumnToBeAveraged: Series.mean,
     * });
     * 
*/ static mean(series: ISeries): number; /** * Computes and returns the mean value of a set of values. * * @returns Returns the mean of the number values in the series. * * @example *
     *
     * const averageSales = salesFigures.mean();
     * 
*/ mean(): number; /** * Static version of the median function for use with {@link DataFrame.summarize} and {@link DataFrame.pivot} functions. * * @param series Input series to find the median of. * * @returns Returns the median of the number values in the series. * * @example *
     *
     * const summary = dataFrame.summarize({
     *      InputColumn: Series.median,
     * });
     * 
*/ static median(series: ISeries): number; /** * Get the median value in the series. * Note that this sorts the series, which can be expensive. * * @returns Returns the median of the values in the series. * * @example *
     *
     * const medianSales = salesFigures.median();
     * 
*/ median(): number; /** * Static version of the mode function for use with {@link DataFrame.summarize} and {@link DataFrame.pivot} functions. * * @param series Input series for which to find the mode. * * @returns Returns the mode of the number values in the series. * * @example *
     *
     * const summary = dataFrame.summarize({
     *      InputColumn: Series.mode,
     * });
     * 
*/ static mode(series: ISeries): any; /** * Get the mode of the values in the series. * The mode is the most frequent value in the series. * Note that this reads the entire series into memory, which can be expensive. * * @returns Returns the mode of the values in the series. * * @example *
     *
     * const modeSales = salesFigures.mode();
     * 
*/ mode(): any; private sumOfSquares(); /** * Static version of the (population) variance function for use with {@link DataFrame.summarize} and {@link DataFrame.pivot} functions. * * @param series Input series for which to find the (population) variance. * * @returns Returns the (population) variance of the values in the series. * * @example *
     *
     * const summary = dataFrame.summarize({
     *      InputColumn: Series.variance,
     * });
     * 
*/ static variance(series: ISeries): number; /** * Get the (population) variance of number values in the series. * * @returns Returns the (population) variance of the values in the series. * * @example *
     *
     * const salesVariance = salesFigures.variance();
     * 
*/ variance(): number; /** * Static version of the (population) standard deviation function for use with {@link DataFrame.summarize} and {@link DataFrame.pivot} functions. * * @param series Input series for which to find the (population) standard deviation. * * @returns Returns the (population) standard deviation of the values in the series. * * @example *
     *
     * const summary = dataFrame.summarize({
     *      InputColumn: Series.std,
     * });
     * 
*/ static std(series: ISeries): number; /** * Get the (population) standard deviation of number values in the series. * * @returns Returns the (population) standard deviation of the values in the series. * * @example *
     *
     * const salesStdDev = salesFigures.std();
     * 
*/ std(): number; /** * Standardize a series of numbers by converting each "standard deviations from the mean". * This converts the input series to Z scores using the population standard deviation. * * @returns A new series containing Z scores computed from the input series. * * @example *
     *
     * const standardizedSeries = series.standardize();
     * 
*/ standardize(): ISeries; /** * Static version of the (sample) variance function for use with {@link DataFrame.summarize} and {@link DataFrame.pivot} functions. * * @param series Input series for which to find the (sample) variance. * * @returns Returns the (sample) variance of the values in the series. * * @example *
     *
     * const summary = dataFrame.summarize({
     *      InputColumn: Series.sampleVariance,
     * });
     * 
*/ static sampleVariance(series: ISeries): number; /** * Get the (sample) variance of number values in the series. * * @returns Returns the (sample) variance of the values in the series. * * @example *
     *
     * const salesVariance = salesFigures.variance();
     * 
*/ sampleVariance(): number; /** * Static version of the (sample) standard deviation function for use with {@link DataFrame.summarize} and {@link DataFrame.pivot} functions. * * @param series Input series for which to find the (sample) standard deviation. * * @returns Returns the (sample) standard deviation of the values in the series. * * @example *
     *
     * const summary = dataFrame.summarize({
     *      InputColumn: Series.sampleStd,
     * });
     * 
*/ static sampleStd(series: ISeries): number; /** * Get the (sample) standard deviation of number values in the series. * * @returns Returns the (sample) standard deviation of the values in the series. * * @example *
     *
     * const salesStdDev = salesFigures.sampleStd();
     * 
*/ sampleStd(): number; /** * Standardize a series of numbers by converting each "standard deviations from the mean". * This converts the input series to Z scores using the sample standard deviation. * * @returns A new series containing Z scores computed from the input series. * * @example *
     *
     * const standardizedSeries = series.sampleStandardize();
     * 
*/ sampleStandardize(): ISeries; /** * Static version of the min function for use with {@link DataFrame.summarize} and {@link DataFrame.pivot} functions. * * @param series Input series to find the minimum of. * * @returns Returns the minimum of number values in the series. * * @example *
     *
     * const summary = dataFrame.summarize({
     *      Column: Series.min,
     * });
     * 
*/ static min(series: ISeries): number; /** * Get the min value in the series. * * @returns Returns the minimum of the number values in the series. * * @example *
     *
     * const minSales = salesFigures.min();
     * 
*/ min(): number; /** * Static version of the max function for use with {@link DataFrame.summarize} and {@link DataFrame.pivot} functions. * * @param series Input series to find the maximum of. * * @returns Returns the maximum of number values in the series. * * @example *
     *
     * const summary = dataFrame.summarize({
     *      Column: Series.max,
     * });
     * 
*/ static max(series: ISeries): number; /** * Get the max value in the series. * * @returns Returns the maximum of the number values in the series. * * @example *
     *
     * const maxSales = salesFigures.max();
     * 
*/ max(): number; /** * Static version of the range function for use with {@link DataFrame.summarize} and {@link DataFrame.pivot} functions. * * @param series Input series for which to find the range of values. * * @returns Returns the range of number values in the series. * * @example *
     *
     * const summary = dataFrame.summarize({
     *      Column: Series.range,
     * });
     * 
*/ static range(series: ISeries): number; /** * Get the range of values in the series. * * @returns Returns the range of the number values in the series. * * @example *
     *
     * const range = salesFigures.range();
     * 
*/ range(): number; /** * Invert the sign of every number value in the series. * This assumes that the input series contains numbers. * * @returns Returns a new series with all number values inverted. * * @example *
     *
     * const inverted = series.invert();
     * 
*/ invert(): ISeries; /** * Counts the number of sequential values where the predicate evaluates to truthy. * Outputs 0 for values when the predicate evaluates to falsy. * * @param predicate User-defined function. Should evaluate to truthy to activate the counter or falsy to deactivate it. * * @returns Returns a new series that counts up the number of sequential values where the predicate evaluates to truthy. 0 values appear when the prediate evaluates to falsy. * * @example *
     *
     * const series = new Series([ 1, 10, 3, 15, 8, 5 ]);
     * const counted = series.counter(value => value >= 3);
     * console.log(counted.toString());
     * 
*/ counter(predicate: PredicateFn): ISeries; /** * Gets a new series in reverse order. * * @return Returns a new series that is the reverse of the original. * * @example *
     *
     * const reversed = series.reverse();
     * 
*/ reverse(): ISeries; /** * Returns only the set of values in the series that are distinct. * Provide a user-defined selector to specify criteria for determining the distinctness. * This can be used to remove duplicate values from the series. * * @param selector Optional user-defined selector function that specifies the criteria used to make comparisons for duplicate values. * * @return Returns a series containing only unique values in the series. * * @example *
     *
     * const uniqueValues = series.distinct(); // Get only non-duplicated value in the series.
     * 
* * @example *
     *
     * const bucketedValues = series.distinct(value => Math.floor(value / 10)); // Lump values into buckets of 10.
     * 
*/ distinct(selector?: SelectorFn): ISeries; /** * Collects values in the series into a new series of groups according to a user-defined selector function. * * @param selector User-defined selector function that specifies the criteriay to group by. * * @return Returns a new series of groups. Each group is a series with values that have been grouped by the 'selector' function. * * @example *
     *
     * const sales = ... product sales ...
     * const salesByProduct = sales.groupBy(sale => sale.ProductId);
     * for (const productSalesGroup of salesByProduct) {
     *      // ... do something with each product group ...
     *      const productId = productSalesGroup.first().ProductId;
     *      const totalSalesForProduct = productSalesGroup.deflate(sale => sale.Amount).sum();
     *      console.log(totalSalesForProduct);
     * }
     * 
*/ groupBy(selector: SelectorWithIndexFn): ISeries>; /** * Collects values in the series into a new series of groups based on if the values are the same or according to a user-defined selector function. * * @param selector Optional selector that specifies the criteria for grouping. * * @return Returns a new series of groups. Each group is a series with values that are the same or have been grouped by the 'selector' function. * * @example *
     *
     * // Some ultra simple stock trading strategy backtesting...
     * const dailyStockPrice = ... daily stock price for a company ...
     * const priceGroups  = dailyStockPrice.groupBy(day => day.close > day.movingAverage);
     * for (const priceGroup of priceGroups) {
     *      // ... do something with each stock price group ...
     *
     *      const firstDay = priceGroup.first();
     *      if (firstDay.close > movingAverage) {
     *          // This group of days has the stock price above its moving average.
     *          // ... maybe enter a long trade here ...
     *      }
     *      else {
     *          // This group of days has the stock price below its moving average.
     *          // ... maybe enter a short trade here ...
     *      }
     * }
     * 
*/ groupSequentialBy(selector?: SelectorFn): ISeries>; /** * Concatenate multiple series into a single series. * * @param series - Array of series to concatenate. * * @returns Returns a single series concatenated from multiple input series. */ static concat(series: ISeries[]): ISeries; /** * Concatenate multiple other series onto this series. * * @param series Multiple arguments. Each can be either a series or an array of series. * * @return Returns a single series concatenated from multiple input series. * * @example *
     *
     * const concatenated = a.concat(b);
     * 
* * @example *
     *
     * const concatenated = a.concat(b, c);
     * 
* * @example *
     *
     * const concatenated = a.concat([b, c]);
     * 
* * @example *
     *
     * const concatenated = a.concat(b, [c, d]);
     * 
* * @example *
     *
     * const otherSeries = [... array of series...];
     * const concatenated = a.concat(otherSeries);
     * 
*/ concat(...series: (ISeries[] | ISeries)[]): ISeries; /** * Zip together multiple series to create a new series. * Preserves the index of the first series. * * @param series - An iterable of series to be zipped. * @param zipper - Selector function that produces a new series based on the input series. * * @returns Returns a single series zipped from multiple input series. */ static zip(series: Iterable>, zipper: ZipNFn): ISeries; /** * Merge together multiple series to create a new series. * Preserves the index of the first series. * * @param s2, s3, s4, s4 Multiple series to zip. * @param zipper User-defined zipper function that merges rows. It produces values for the new series based-on values from the input series. * * @return Returns a single series merged from multiple input series. * * @example *
    *
    * const a = new Series([1, 2, 3]);
    * const b = new Series([10, 20, 30]);
    * const zipped = a.zip(b (valueA, valueB) => valueA + valueB);
    * 
*/ zip(s2: ISeries, zipper: Zip2Fn): ISeries; zip(s2: ISeries, s3: ISeries, zipper: Zip3Fn): ISeries; zip(s2: ISeries, s3: ISeries, s4: ISeries, zipper: Zip3Fn): ISeries; /** * Sorts the series in ascending order by a value defined by the user-defined selector function. * * @param selector User-defined selector function that selects the value to sort by. * * @return Returns a new series that has been ordered accorrding to the value chosen by the selector function. * * @example *
     *
     * const orderedSeries = series.orderBy(value => value);
     * 
* * @example *
     *
     * const orderedSeries = series.orderBy(value => value.NestedValue);
     * 
*/ orderBy(selector: SelectorWithIndexFn): IOrderedSeries; /** * Sorts the series in descending order by a value defined by the user-defined selector function. * * @param selector User-defined selector function that selects the value to sort by. * * @return Returns a new series that has been ordered accorrding to the value chosen by the selector function. * * @example *
     *
     * const orderedSeries = series.orderByDescending(value => value);
     * 
* * @example *
     *
     * const orderedSeries = series.orderByDescending(value => value.NestedValue);
     * 
*/ orderByDescending(selector: SelectorWithIndexFn): IOrderedSeries; /** * Creates a new series by merging two input dataframes. * The resulting series contains the union of value from the two input series. * These are the unique combination of values in both series. * This is basically a concatenation and then elimination of duplicates. * * @param other The other series to merge. * @param selector Optional user-defined selector function that selects the value to compare to determine distinctness. * * @return Returns the union of the two series. * * @example *
     *
     * const seriesA = ...
     * const seriesB = ...
     * const merged = seriesA.union(seriesB);
     * 
* * @example *
     *
     * // Merge two sets of customer records that may contain the same
     * // customer record in each set. This is basically a concatenation
     * // of the series and then an elimination of any duplicate records
     * // that result.
     * const customerRecordsA = ...
     * const customerRecordsB = ...
     * const mergedCustomerRecords = customerRecordsA.union(
     *      customerRecordsB,
     *      customerRecord => customerRecord.CustomerId
     * );
     * 
* * * @example *
     *
     * // Note that you can achieve the exact same result as the previous
     * // example by doing a {@link Series.concat) and {@link Series.distinct}
     * // of the input series and then an elimination of any duplicate records
     * // that result.
     * const customerRecordsA = ...
     * const customerRecordsB = ...
     * const mergedCustomerRecords = customerRecordsA
     *      .concat(customerRecordsB)
     *      .distinct(customerRecord => customerRecord.CustomerId);
     * 
* */ union(other: ISeries, selector?: SelectorFn): ISeries; /** * Creates a new series by merging two input series. * The resulting series contains the intersection of values from the two input series. * These are only the values that appear in both series. * * @param inner The inner series to merge (the series you call the function on is the 'outer' series). * @param outerSelector Optional user-defined selector function that selects the key from the outer series that is used to match the two series. * @param innerSelector Optional user-defined selector function that selects the key from the inner series that is used to match the two series. * * @return Returns a new series that contains the intersection of values from the two input series. * * @example *
     *
     * const seriesA = ...
     * const seriesB = ...
     * const mergedDf = seriesA.intersection(seriesB);
     * 
* * @example *
     *
     * // Merge two sets of customer records to find only the
     * // customers that appears in both.
     * const customerRecordsA = ...
     * const customerRecordsB = ...
     * const intersectionOfCustomerRecords = customerRecordsA.intersection(
     *      customerRecordsB,
     *      customerRecord => customerRecord.CustomerId
     * );
     * 
*/ intersection(inner: ISeries, outerSelector?: SelectorFn, innerSelector?: SelectorFn): ISeries; /** * Creates a new series by merging two input series. * The resulting series contains only the values from the 1st series that don't appear in the 2nd series. * This is essentially subtracting the values from the 2nd series from the 1st and creating a new series with the remaining values. * * @param inner The inner series to merge (the series you call the function on is the 'outer' series). * @param outerSelector Optional user-defined selector function that selects the key from the outer series that is used to match the two series. * @param innerSelector Optional user-defined selector function that selects the key from the inner series that is used to match the two series. * * @return Returns a new series that contains only the values from the 1st series that don't appear in the 2nd series. * * @example *
     *
     * const seriesA = ...
     * const seriesB = ...
     * const remainingDf = seriesA.except(seriesB);
     * 
* * @example *
     *
     * // Find the list of customers haven't bought anything recently.
     * const allCustomers = ... list of all customers ...
     * const recentCustomers = ... list of customers who have purchased recently ...
     * const remainingCustomers = allCustomers.except(
     *      recentCustomers,
     *      customerRecord => customerRecord.CustomerId
     * );
     * 
*/ except(inner: ISeries, outerSelector?: SelectorFn, innerSelector?: SelectorFn): ISeries; /** * Creates a new series by merging two input series. * The resulting dataframe contains only those value that have matching keys in both input series. * * @param inner The 'inner' series to join (the series you are callling the function on is the 'outer' series). * @param outerKeySelector User-defined selector function that chooses the join key from the outer series. * @param innerKeySelector User-defined selector function that chooses the join key from the inner series. * @param resultSelector User-defined function that merges outer and inner values. * * @return Returns the new merged series. * * @example *
      *
      * // Join together two sets of customers to find those
      * // that have bought both product A and product B.
      * const customerWhoBoughtProductA = ...
      * const customerWhoBoughtProductB = ...
      * const customersWhoBoughtBothProductsDf = customerWhoBoughtProductA.join(
      *          customerWhoBoughtProductB,
      *          customerA => customerA.CustomerId, // Join key.
      *          customerB => customerB.CustomerId, // Join key.
      *          (customerA, customerB) => {
      *              return {
      *                  // ... merge the results ...
      *              };
      *          }
      *      );
      * 
*/ join(inner: ISeries, outerKeySelector: SelectorFn, innerKeySelector: SelectorFn, resultSelector: JoinFn): ISeries; /** * Creates a new series by merging two input series. * The resulting series contains only those values that are only present in one or the other of the series, not both. * * @param inner The 'inner' series to join (the series you are callling the function on is the 'outer' series). * @param outerKeySelector User-defined selector function that chooses the join key from the outer series. * @param innerKeySelector User-defined selector function that chooses the join key from the inner series. * @param resultSelector User-defined function that merges outer and inner values. * * Implementation from here: * * http://blogs.geniuscode.net/RyanDHatch/?p=116 * * @return Returns the new merged series. * * @example *
     *
     * // Join together two sets of customers to find those
     * // that have bought either product A or product B, not not both.
     * const customerWhoBoughtProductA = ...
     * const customerWhoBoughtProductB = ...
     * const customersWhoBoughtEitherProductButNotBothDf = customerWhoBoughtProductA.joinOuter(
     *          customerWhoBoughtProductB,
     *          customerA => customerA.CustomerId, // Join key.
     *          customerB => customerB.CustomerId, // Join key.
     *          (customerA, customerB) => {
     *              return {
     *                  // ... merge the results ...
     *              };
     *          }
     *      );
     * 
*/ joinOuter(inner: ISeries, outerKeySelector: SelectorFn, innerKeySelector: SelectorFn, resultSelector: JoinFn): ISeries; /** * Creates a new series by merging two input series. * The resulting series contains only those values that are present either in both series or only in the outer (left) series. * * @param inner The 'inner' series to join (the series you are callling the function on is the 'outer' series). * @param outerKeySelector User-defined selector function that chooses the join key from the outer series. * @param innerKeySelector User-defined selector function that chooses the join key from the inner series. * @param resultSelector User-defined function that merges outer and inner values. * * Implementation from here: * * http://blogs.geniuscode.net/RyanDHatch/?p=116 * * @return Returns the new merged series. * * @example *
     *
     * // Join together two sets of customers to find those
     * // that have bought either just product A or both product A and product B.
     * const customerWhoBoughtProductA = ...
     * const customerWhoBoughtProductB = ...
     * const boughtJustAorAandB = customerWhoBoughtProductA.joinOuterLeft(
     *          customerWhoBoughtProductB,
     *          customerA => customerA.CustomerId, // Join key.
     *          customerB => customerB.CustomerId, // Join key.
     *          (customerA, customerB) => {
     *              return {
     *                  // ... merge the results ...
     *              };
     *          }
     *      );
     * 
*/ joinOuterLeft(inner: ISeries, outerKeySelector: SelectorFn, innerKeySelector: SelectorFn, resultSelector: JoinFn): ISeries; /** * Creates a new series by merging two input series. * The resulting series contains only those values that are present either in both series or only in the inner (right) series. * * @param inner The 'inner' series to join (the series you are callling the function on is the 'outer' series). * @param outerKeySelector User-defined selector function that chooses the join key from the outer series. * @param innerKeySelector User-defined selector function that chooses the join key from the inner series. * @param resultSelector User-defined function that merges outer and inner values. * * Implementation from here: * * http://blogs.geniuscode.net/RyanDHatch/?p=116 * * @return Returns the new merged series. * * @example *
     *
     * // Join together two sets of customers to find those
     * // that have bought either just product B or both product A and product B.
     * const customerWhoBoughtProductA = ...
     * const customerWhoBoughtProductB = ...
     * const boughtJustAorAandB = customerWhoBoughtProductA.joinOuterRight(
     *          customerWhoBoughtProductB,
     *          customerA => customerA.CustomerId, // Join key.
     *          customerB => customerB.CustomerId, // Join key.
     *          (customerA, customerB) => {
     *              return {
     *                  // ... merge the results ...
     *              };
     *          }
     *      );
     * 
*/ joinOuterRight(inner: ISeries, outerKeySelector: SelectorFn, innerKeySelector: SelectorFn, resultSelector: JoinFn): ISeries; /** * Produces a new series with all string values truncated to the requested maximum length. * * @param maxLength - The maximum length of the string values after truncation. * * @returns Returns a new series with strings that are truncated to the specified maximum length. * * @example *
     *
     * const truncated = series.truncateStrings(10); // Truncate all string values to max length of 10 characters.
     * 
*/ truncateStrings(maxLength: number): ISeries; /** * Produces a new series with all number values rounded to the specified number of places. * * @param numDecimalPlaces The number of decimal places, defaults to 2. * * @returns Returns a new series with all number values rounded to the specified number of places. * * @example *
     *
     * const series = ... your data series ...
     * const rounded = series.round(); // Round numbers to two decimal places.
     * 
* * @example *
     *
     * const series = ... your data series ...
     * const rounded = series.round(3); // Round numbers to three decimal places.
     * 
*/ round(numDecimalPlaces?: number): ISeries; /** * Insert a pair at the start of the series. * Doesn't modify the original series! The returned series is entirely new and contains values from the original series plus the inserted pair. * * @param pair The index/value pair to insert. * * @return Returns a new series with the specified pair inserted. * * @example *
     *
     * const newIndex = ... index of the new row ...
     * const newRow = ... the new data row to insert ...
     * const insertedSeries = series.insertPair([newIndex, newRows]);
     * 
*/ insertPair(pair: [IndexT, ValueT]): ISeries; /** * Append a pair to the end of a series. * Doesn't modify the original series! The returned series is entirely new and contains values from the original series plus the appended pair. * * @param pair The index/value pair to append. * * @return Returns a new series with the specified pair appended. * * @example *
     *
     * const newIndex = ... index of the new row ...
     * const newRow = ... the new data row to append ...
     * const appendedSeries = series.appendPair([newIndex, newRows]);
     * 
*/ appendPair(pair: [IndexT, ValueT]): ISeries; /** * Removes values from the series by index. */ remove(index: IndexT): ISeries; /** * Fill gaps in a series. * * @param comparer User-defined comparer function that is passed pairA and pairB, two consecutive values, return truthy if there is a gap between the value, or falsey if there is no gap. * @param generator User-defined generator function that is passed pairA and pairB, two consecutive values, returns an array of pairs that fills the gap between the values. * * @return Returns a new series with gaps filled in. * * @example *
     *
     *   var sequenceWithGaps = ...
     *
     *  // Predicate that determines if there is a gap.
     *  var gapExists = (pairA, pairB) => {
     *      // Returns true if there is a gap.
     *      return true;
     *  };
     *
     *  // Generator function that produces new rows to fill the game.
     *  var gapFiller = (pairA, pairB) => {
     *      // Create an array of index, value pairs that fill the gaps between pairA and pairB.
     *      return [
     *          newPair1,
     *          newPair2,
     *          newPair3,
     *      ];
     *  };
     *
     *  var sequenceWithoutGaps = sequenceWithGaps.fillGaps(gapExists, gapFiller);
     * 
*/ fillGaps(comparer: ComparerFn<[IndexT, ValueT], [IndexT, ValueT]>, generator: GapFillFn<[IndexT, ValueT], [IndexT, ValueT]>): ISeries; /** * Returns the specified default series if the input series is empty. * * @param defaultSequence Default series to return if the input series is empty. * * @return Returns 'defaultSequence' if the input series is empty. * * @example *
     *
     * const emptySeries = new Series();
     * const defaultSeries = new Series([ 1, 2, 3 ]);
     * expect(emptyDataFrame.defaultIfEmpty(defaultSeries)).to.eql(defaultSeries);
     * 
* * @example *
     *
     * const nonEmptySeries = new Series([ 100 ]);
     * const defaultSeries = new Series([ 1, 2, 3 ]);
     * expect(nonEmptySeries.defaultIfEmpty(defaultSeries)).to.eql(nonEmptySeries);
     * 
*/ defaultIfEmpty(defaultSequence: ValueT[] | ISeries): ISeries; /** * Detect the the frequency of the types of the values in the series. * This is a good way to understand the shape of your data. * * @return Returns a {@link DataFrame} with rows that confirm to {@link ITypeFrequency} that describes the data types contained in the original series. * * @example *
     *
     * const dataTypes = series.detectTypes();
     * console.log(dataTypes.toString());
     * 
*/ detectTypes(): IDataFrame; /** * Detect the frequency of the values in the series. * This is a good way to understand the shape of your data. * * @return Returns a {@link DataFrame} with rows that conform to {@link IValueFrequency} that describes the values contained in the original series. * * @example *
     *
     * const dataValues = series.detectValues();
     * console.log(dataValues.toString());
     * 
*/ detectValues(): IDataFrame; /** * Organise all values in the series into the specified number of buckets. * Assumes that the series is a series of numbers. * * WARNING: This function is deprecated and will be removed in the future. * * @param numBuckets - The number of buckets to create. * * @returns Returns a dataframe containing bucketed values. The input values are divided up into these buckets. * * @example *
     *
     * const buckets = series.bucket(20); // Distribute values into 20 evenly spaced buckets.
     * console.log(buckets.toString());
     * 
*/ bucket(numBuckets: number): IDataFrame; /** * Counts frequencies in the series to produce a frequency table. * * @param options - Options for computing the frequency table (e.g. `numGroups` which defaults to 10). * * @returns Returns a dataframe for the frequency table showing the frequency for the band of values in each group. * * @example *
     *
     * const series = new Series([ 1, 2, 3, 4 ]);
     * // Or
     * const series = dataFrame.getSeries("SomeColumn");
     *
     * const frequencyTable = series.frequency();
     * console.log(frequencyTable.toArray());
     * 
* @example *
     *
     * const series = new Series([ 37, 63, 56, 54, 39, 49, 55, 114, 59, 55 ]);
     * const frequencyTable = series.frequency({
     *      lower: 40,
     *      upper: 90,
     *      interval: 10,
     * })
     * console.log(frequencyTable.toArray());
     * 
*/ frequency(options?: IFrequencyTableOptions): IDataFrame; /*** * Allows the series to be queried to confirm that it is actually a series. * Used from JavaScript to tell the difference between a Series and a DataFrame. * * @return Returns the string "series". */ getTypeCode(): string; }