import { Float32Buffer, Float64Buffer, Int16Buffer, Int32Buffer, Int64Buffer, Int8Buffer, MemoryData, Uint16Buffer, Uint32Buffer, Uint64Buffer, Uint8Buffer, Uint8ClampedBuffer } from '@rapidsai/cuda'; import { DeviceBuffer, MemoryResource } from '@rapidsai/rmm'; import * as arrow from 'apache-arrow'; import { JavaScriptArrayDataType } from 'apache-arrow/interfaces'; import { Column } from './column'; import { DisplayOptions } from './dataframe/print'; import { Bool8, Categorical, DataType, Float32, Float64, IndexType, Int16, Int32, Int64, Int8, Integral, List, Numeric, Struct, TimestampDay, TimestampMicrosecond, TimestampMillisecond, TimestampNanosecond, TimestampSecond, Uint16, Uint32, Uint64, Uint8, Utf8String } from './types/dtypes'; import { DuplicateKeepOption, NullOrder } from './types/enums'; import { ArrowToCUDFType, CommonType } from './types/mappings'; export declare type SeriesProps = { type: T; data?: DeviceBuffer | MemoryData | arrow.Vector | T['scalarType'][] | null; offset?: number; length?: number; nullCount?: number; nullMask?: DeviceBuffer | MemoryData | any[] | boolean | null; children?: ReadonlyArray | null; } | { type: T; data?: DeviceBuffer | MemoryData | arrow.Vector | (T['scalarType'] | null | undefined)[] | null; offset?: number; length?: number; nullCount?: number; nullMask?: never; children?: ReadonlyArray | null; }; export declare type Series = { [arrow.Type.NONE]: never; [arrow.Type.Null]: never; [arrow.Type.Int]: never; [arrow.Type.Int8]: Int8Series; [arrow.Type.Int16]: Int16Series; [arrow.Type.Int32]: Int32Series; [arrow.Type.Int64]: Int64Series; [arrow.Type.Uint8]: Uint8Series; [arrow.Type.Uint16]: Uint16Series; [arrow.Type.Uint32]: Uint32Series; [arrow.Type.Uint64]: Uint64Series; [arrow.Type.Float]: never; [arrow.Type.Float16]: never; [arrow.Type.Float32]: Float32Series; [arrow.Type.Float64]: Float64Series; [arrow.Type.Binary]: never; [arrow.Type.Utf8]: StringSeries; [arrow.Type.Bool]: Bool8Series; [arrow.Type.Decimal]: never; [arrow.Type.Date]: never; [arrow.Type.DateDay]: TimestampDaySeries; [arrow.Type.DateMillisecond]: TimestampMillisecondSeries; [arrow.Type.Time]: never; [arrow.Type.TimeSecond]: never; [arrow.Type.TimeMillisecond]: never; [arrow.Type.TimeMicrosecond]: never; [arrow.Type.TimeNanosecond]: never; [arrow.Type.Timestamp]: never; [arrow.Type.TimestampSecond]: TimestampSecondSeries; [arrow.Type.TimestampMillisecond]: TimestampMillisecondSeries; [arrow.Type.TimestampMicrosecond]: TimestampMicrosecondSeries; [arrow.Type.TimestampNanosecond]: TimestampNanosecondSeries; [arrow.Type.Interval]: never; [arrow.Type.IntervalDayTime]: never; [arrow.Type.IntervalYearMonth]: never; [arrow.Type.List]: ListSeries<(T extends List ? T['valueType'] : any)>; [arrow.Type.Struct]: StructSeries<(T extends Struct ? T['dataTypes'] : any)>; [arrow.Type.Union]: never; [arrow.Type.DenseUnion]: never; [arrow.Type.SparseUnion]: never; [arrow.Type.FixedSizeBinary]: never; [arrow.Type.FixedSizeList]: never; [arrow.Type.Map]: never; [arrow.Type.Dictionary]: CategoricalSeries<(T extends arrow.Dictionary ? T['valueType'] : any)>; }[T['TType']]; /** * One-dimensional GPU array */ export declare class AbstractSeries { /** * Create a new cudf.Series from an apache arrow vector * * @example * ```typescript * import {Series, Int32} from '@rapidsai/cudf'; * import * as arrow from 'apache-arrow'; * * const arrow_vec = arrow.vectorFromArray(new Int32Array([1,2,3,4]))); * const a = Series.new(arrow_vec); // Int32Series [1, 2, 3, 4] * * const arrow_vec_list = arrow.vectorFromArray( * [[0, 1, 2], [3, 4, 5], [6, 7, 8]], * new arrow.List(arrow.Field.new({ name: 'ints', type: new arrow.Int32 })), * ); * * const b = Series.new(arrow_vec_list) // ListSeries [[0, 1, 2], [3, 4, 5], [6, 7, 8]] * * const arrow_vec_struct = arrow.vectorFromArray( * [{ x: 0, y: 3 }, { x: 1, y: 4 }, { x: 2, y: 5 }], * new arrow.Struct([ * arrow.Field.new({ name: 'x', type: new arrow.Int32 }), * arrow.Field.new({ name: 'y', type: new arrow.Int32 }) * ]), * ); * * const c = Series.new(arrow_vec_struct); * // StructSeries [{ x: 0, y: 3 }, { x: 1, y: 4 }, { x: 2, y: 5 }] * ``` */ static new(input: T): Series>; /** * Create a new cudf.Series from SeriesProps or a cudf.Column * * @example * ```typescript * import {Series, Int32} from '@rapidsai/cudf'; * * //using SeriesProps * const a = Series.new({type: new Int32, data: [1, 2, 3, 4]}); // Int32Series [1, 2, 3, 4] * * //using underlying cudf.Column * const b = Series.new(a._col); // Int32Series [1, 2, 3, 4] * ``` */ static new(input: T): T; static new(input: Column): Series; static new(input: SeriesProps): Series; /** * Create a new cudf.Int8Series * * @example * ```typescript * import { * Series, * Int8Series, * Int8 * } from '@rapidsai/cudf'; * * // Int8Series [1, 2, 3] * const a = Series.new(new Int8Array([1, 2, 3])); * const b = Series.new(new Int8Buffer([1, 2, 3])); * ``` */ static new(input: Int8Array | Int8Buffer): Series; /** * Create a new cudf.Int16Series * * @example * ```typescript * import { * Series, * Int16Series, * Int16 * } from '@rapidsai/cudf'; * * // Int16Series [1, 2, 3] * const a = Series.new(new Int16Array([1, 2, 3])); * const b = Series.new(new Int16Buffer([1, 2, 3])); * ``` */ static new(input: Int16Array | Int16Buffer): Series; /** * Create a new cudf.Int32Series * * @example * ```typescript * import { * Series, * Int32Series, * Int32 * } from '@rapidsai/cudf'; * * // Int32Series [1, 2, 3] * const a = Series.new(new Int32Array([1, 2, 3])); * const b = Series.new(new Int32Buffer([1, 2, 3])); * ``` */ static new(input: Int32Array | Int32Buffer): Series; /** * Create a new cudf.Uint8Series * * @example * ```typescript * import { * Series, * Uint8Series, * Uint8 * } from '@rapidsai/cudf'; * * // Uint8Series [1, 2, 3] * const a = Series.new(new Uint8Array([1, 2, 3])); * const b = Series.new(new Uint8Buffer([1, 2, 3])); * const c = Series.new(new Uint8ClampedArray([1, 2, 3])); * const d = Series.new(new Uint8ClampedBuffer([1, 2, 3])); * ``` */ static new(input: Uint8Array | Uint8Buffer | Uint8ClampedArray | Uint8ClampedBuffer): Series; /** * Create a new cudf.Uint16Series * * @example * ```typescript * import { * Series, * Uint16Series, * Uint16 * } from '@rapidsai/cudf'; * * // Uint16Series [1, 2, 3] * const a = Series.new(new Uint16Array([1, 2, 3])); * const b = Series.new(new Uint16Buffer([1, 2, 3])); * ``` */ static new(input: Uint16Array | Uint16Buffer): Series; /** * Create a new cudf.Uint32Series * * @example * ```typescript * import { * Series, * Uint32Series, * Uint32 * } from '@rapidsai/cudf'; * * // Uint32Series [1, 2, 3] * const a = Series.new(new Uint32Array([1, 2, 3])); * const b = Series.new(new Uint32Buffer([1, 2, 3])); * ``` */ static new(input: Uint32Array | Uint32Buffer): Series; /** * Create a new cudf.Uint64Series * * @example * ```typescript * import { * Series, * Uint64Series, * Uint64 * } from '@rapidsai/cudf'; * * // Uint64Series [1n, 2n, 3n] * const a = Series.new(new BigUint64Array([1n, 2n, 3n])); * const b = Series.new(new Uint64Buffer([1n, 2n, 3n])); * ``` */ static new(input: BigUint64Array | Uint64Buffer): Series; /** * Create a new cudf.Float32Series * * @example * ```typescript * import { * Series, * Float32Series, * Float32 * } from '@rapidsai/cudf'; * * // Float32Series [1, 2, 3] * const a = Series.new(new Float32Array([1, 2, 3])); * const b = Series.new(new Float32Buffer([1, 2, 3])); * ``` */ static new(input: Float32Array | Float32Buffer): Series; /** * Create a new cudf.StringSeries * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * // StringSeries ["foo", "bar", "test", null] * const a = Series.new(["foo", "bar", "test", null]); * ``` */ static new(input: (string | null | undefined)[]): Series; /** * Create a new cudf.Float64Series * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * // Float64Series [1, 2, 3, null, 4] * const a = Series.new([1, 2, 3, undefined, 4]); * ``` */ static new(input: (number | null | undefined)[] | Float64Array | Float64Buffer): Series; /** * Create a new cudf.Int64Series * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * // Int64Series [1n, 2n, 3n, null, 4n] * const a = Series.new([1n, 2n, 3n, undefined, 4n]); * ``` */ static new(input: (bigint | null | undefined)[] | BigInt64Array | Int64Buffer): Series; /** * Create a new cudf.Bool8Series * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * // Bool8Series [true, false, null, false] * const a = Series.new([true, false, undefined, false]); * ``` */ static new(input: (boolean | null | undefined)[]): Series; /** * Create a new cudf.TimestampMillisecondSeries * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * // TimestampMillisecondSeries [2021-05-13T00:00:00.000Z, null, 2021-05-13T00:00:00.000Z, * null] const a = Series.new([new Date(), undefined, new Date(), undefined]); * ``` */ static new(input: (Date | null | undefined)[]): Series; /** * Create a new cudf.ListSeries that contain cudf.StringSeries elements. * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * // ListSeries [["foo", "bar"], ["test", null]] * const a = Series.new([["foo", "bar"], ["test",null]]); * a.getValue(0) // StringSeries ["foo", "bar"] * a.getValue(1) // StringSeries ["test", null] * ``` */ static new(input: (string | null | undefined)[][]): Series>; /** * Create a new cudf.ListSeries that contain cudf.Float64Series elements. * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * // ListSeries [[1, 2], [3, null, 4]] * const a = Series.new([[1, 2], [3, undefined, 4]]); * a.getValue(0) // Float64Series [1, 2] * a.getValue(1) // Float64Series [3, null, 4] * ``` */ static new(input: (number | null | undefined)[][]): Series>; /** * Create a new cudf.ListSeries that contain cudf.Int64Series elements. * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * // ListSeries [[1n, 2n], [3n, null, 4n]] * const a = Series.new([[1n, 2n], [3n, undefined, 4n]]); * a.getValue(0) // Int64Series [1n, 2n] * a.getValue(1) // Int64Series [3n, null, 4n] * ``` */ static new(input: (bigint | null | undefined)[][]): Series>; /** * Create a new cudf.ListSeries that contain cudf.Bool8Series elements. * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * // ListSeries [[true, false], [null, false]] * const a = Series.new([[true, false], [undefined, false]]); * a.getValue(0) // Bool8Series [true, false] * a.getValue(1) // Bool8Series [null, false] * ``` */ static new(input: (boolean | null | undefined)[][]): Series>; /** * Create a new cudf.ListSeries that contain cudf.TimestampMillisecondSeries elements. * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * // ListSeries [[2021-05-13T00:00:00.000Z, null], [null, 2021-05-13T00:00:00.000Z]] * const a = Series.new([[new Date(), undefined], [undefined, new Date()]]); * a.getValue(0) // TimestampMillisecondSeries [2021-05-13T00:00:00.000Z, null] * a.getValue(1) // TimestampMillisecondSeries [null, 2021-05-13T00:00:00.000Z] * ``` */ static new(input: (Date | null | undefined)[][]): Series>; static new(input: T): Series>>; static new(input: AbstractSeries | Column | SeriesProps | arrow.Vector | (string | null | undefined)[] | (number | null | undefined)[] | (bigint | null | undefined)[] | (boolean | null | undefined)[] | (Date | null | undefined)[] | (string | null | undefined)[][] | (number | null | undefined)[][] | (bigint | null | undefined)[][] | (boolean | null | undefined)[][] | (Date | null | undefined)[][]): Series; /** * Constructs a Series from a text file path. * * @note If delimiter is omitted, the default is ''. * * @param filepath Path of the input file. * @param delimiter Optional delimiter. * * @returns StringSeries from the file, split by delimiter. * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * const infile = Series.readText('./inputAsciiFile.txt') * ``` */ static readText(filepath: string, delimiter: string): Series; /** * Constructs a Series with a sequence of values. * * @note If init is omitted, the default is 0. * @note If step is omitted, the default is 1. * @note If type is omitted, the default is Int32. * * @param opts Options for creating the sequence * @returns Series with the sequence * * @example * ```typescript * import {Series, Int64, Float32} from '@rapidsai/cudf'; * * Series.sequence({size: 5}).toArray() // Int32Array[0, 1, 2, 3, 4] * Series.sequence({size: 5, init: 5}).toArray() // Int32Array[5, 6, 7, 8, 9] * Series * .sequence({ size: 5, init: 0, type: new Int64 }) * .toArray() // BigInt64Array[0n, 1n, 2n, 3n, 4n] * Series * .sequence({ size: 5, step: 2, init: 1, type: new Float32 }) * .toArray() // Float32Array[1, 3, 5, 7, 9] * ``` */ static sequence(opts: { size: number; type?: U; init?: U['scalarType']; step?: U['scalarType']; memoryResource?: MemoryResource; }): Series; /** @ignore */ _col: Column; protected constructor(col: Column); /** * The data type of elements in the underlying data. */ get type(): T; /** * The DeviceBuffer for for the validity bitmask in GPU memory. */ get mask(): import("@rapidsai/rmm/build/js/node_rmm").DeviceBuffer; /** * The offset of elements in this Series underlying Column. */ get offset(): number; /** * The number of elements in this Series. */ get length(): number; /** * A boolean indicating whether a validity bitmask exists. */ get nullable(): boolean; /** * Whether the Series contains null elements. */ get hasNulls(): boolean; /** * The number of null elements in this Series. */ get nullCount(): number; /** * The number of child columns in this Series. */ get numChildren(): number; /** * Casts the values to a new dtype (similar to `static_cast` in C++). * * @param dataType The new dtype. * @param memoryResource The optional MemoryResource used to allocate the result Series's device * memory. * @returns Series of same size as the current Series containing result of the `cast` operation. * @example * ```typescript * import {Series, Bool8, Int32} from '@rapidsai/cudf'; * * const a = Series.new({type:new Int32, data: [1,0,1,0]}); * * a.cast(new Bool8); // Bool8Series [true, false, true, false]; * ``` */ cast(dataType: R, memoryResource?: MemoryResource): Series; _castAsBool8(_memoryResource?: MemoryResource): Series; _castAsInt8(_memoryResource?: MemoryResource): Series; _castAsInt16(_memoryResource?: MemoryResource): Series; _castAsInt32(_memoryResource?: MemoryResource): Series; _castAsInt64(_memoryResource?: MemoryResource): Series; _castAsUint8(_memoryResource?: MemoryResource): Series; _castAsUint16(_memoryResource?: MemoryResource): Series; _castAsUint32(_memoryResource?: MemoryResource): Series; _castAsUint64(_memoryResource?: MemoryResource): Series; _castAsFloat32(_memoryResource?: MemoryResource): Series; _castAsFloat64(_memoryResource?: MemoryResource): Series; _castAsString(_memoryResource?: MemoryResource): Series; _castAsTimeStampDay(_memoryResource?: MemoryResource): Series; _castAsTimeStampSecond(_memoryResource?: MemoryResource): Series; _castAsTimeStampMillisecond(_memoryResource?: MemoryResource): Series; _castAsTimeStampMicrosecond(_memoryResource?: MemoryResource): Series; _castAsTimeStampNanosecond(_memoryResource?: MemoryResource): Series; _castAsCategorical(type: R, memoryResource?: MemoryResource): Series; /** * Concat a Series to the end of the caller, returning a new Series of a common dtype. * * @param other The Series to concat to the end of the caller. * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * Series.new([1, 2, 3]).concat(Series.new([4, 5, 6])) // [1, 2, 3, 4, 5, 6] * ``` */ concat>(other: R, memoryResource?: MemoryResource): Series>; /** * Return the number of non-null elements in the Series. * * @returns The number of non-null elements * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * Series.new([1, 2, 3]).countNonNulls(); // 3 * Series.new([1, null, 3]).countNonNulls(); // 2 * ``` */ countNonNulls(): number; /** * @summary Explicitly free the device memory associated with this Series. */ dispose(): void; /** * Encode the Series values into integer labels. * * * @param categories The optional Series of values to encode into integers. Defaults to the * unique elements in this Series. * @param type The optional integer DataType to use for the returned Series. Defaults to * Uint32. * @param nullSentinel The optional value used to indicate missing category. Defaults to -1. * @param memoryResource The optional MemoryResource used to allocate the result Column's * device memory. * @returns A sequence of encoded integer labels with values between `0` and `n-1` * categories, and `nullSentinel` for any null values */ encodeLabels(categories?: Series, type?: R, nullSentinel?: R['scalarType'], memoryResource?: MemoryResource): Series; /** * Fills a range of elements in a column out-of-place with a scalar value. * * @param begin The starting index of the fill range (inclusive). * @param end The index of the last element in the fill range (exclusive), default * this.length * . * @param value The scalar value to fill. * @param memoryResource The optional MemoryResource used to allocate the result Column's * device memory. * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * // Float64Series * Series.new([1, 2, 3]).fill(0) // [0, 0, 0] * // StringSeries * Series.new(["foo", "bar", "test"]).fill("rplc", 0, 1) // ["rplc", "bar", "test"] * // Bool8Series * Series.new([true, true, true]).fill(false, 1) // [true, false, false] * ``` */ fill(value: T['scalarType'], begin?: number, end?: number, memoryResource?: MemoryResource): Series; /** * Fills a range of elements in-place in a column with a scalar value. * * @param begin The starting index of the fill range (inclusive) * @param end The index of the last element in the fill range (exclusive) * @param value The scalar value to fill * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * // Float64Series * Series.new([1, 2, 3]).fillInPlace(0) // [0, 0, 0] * // StringSeries * Series.new(["foo", "bar", "test"]).fillInPlace("rplc", 0, 1) // ["rplc", "bar", "test"] * // Bool8Series * Series.new([true, true, true]).fillInPlace(false, 1) // [true, false, false] * ``` */ fillInPlace(value: T['scalarType'], begin?: number, end?: number): this; /** * Replace null values with a scalar value. * * @param value The scalar value to use in place of nulls. * @param memoryResource The optional MemoryResource used to allocate the result Column's * device memory. * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * // Float64Series * Series.new([1, null, 3]).replaceNulls(-1) // [1, -1, 3] * // StringSeries * Series.new(["foo", "bar", null]).replaceNulls("rplc") // ["foo", "bar", "rplc"] * // Bool8Series * Series.new([null, true, true]).replaceNulls(false) // [true, true, true] * ``` */ replaceNulls(value: T['scalarType'] | any, memoryResource?: MemoryResource): Series; /** * Replace null values with the corresponding elements from another Series. * * @param value The Series to use in place of nulls. * @param memoryResource The optional MemoryResource used to allocate the result Column's * device memory. * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * const replace = Series.new([10, 10, 10]); * const replaceBool = Series.new([false, false, false]); * * // Float64Series * Series.new([1, null, 3]).replaceNulls(replace) // [1, 10, 3] * // StringSeries * Series.new(["foo", "bar", null]).replaceNulls(replace) // ["foo", "bar", "10"] * // Bool8Series * Series.new([null, true, true]).replaceNulls(replaceBool) // [false, true, true] * ``` */ replaceNulls(value: Series, memoryResource?: MemoryResource): Series; /** * Replace null values with the non-null value following the null value in the same series. * * @param memoryResource The optional MemoryResource used to allocate the result Column's * device memory. * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * // Float64Series * Series.new([1, null, 3]).replaceNullsFollowing() // [1, 3, 3] * // StringSeries * Series.new(["foo", "bar", null]).replaceNullsFollowing() // ["foo", "bar", null] * Series.new(["foo", null, "bar"]).replaceNullsFollowing() // ["foo", "bar", "bar"] * // Bool8Series * Series.new([null, true, true]).replaceNullsFollowing() // [true, true, true] * ``` */ replaceNullsFollowing(memoryResource?: MemoryResource): Series; /** * Replace null values with the non-null value preceding the null value in the same series. * * @param memoryResource The optional MemoryResource used to allocate the result Column's * device memory. * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * // Float64Series * Series.new([1, null, 3]).replaceNullsPreceding() // [1, 1, 3] * // StringSeries * Series.new([null, "foo", "bar"]).replaceNullsPreceding() // [null, "foo", "bar"] * Series.new(["foo", null, "bar"]).replaceNullsPreceding() // ["foo", "foo", "bar"] * // Bool8Series * Series.new([true, null, false]).replaceNullsPreceding() // [true, true, false] * ``` */ replaceNullsPreceding(memoryResource?: MemoryResource): Series; /** * Returns a new series with reversed elements. * * @param memoryResource An optional MemoryResource used to allocate the result's device memory. * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * // Float64Series * Series.new([1, 2, 3]).reverse() // [3, 2, 1] * // StringSeries * Series.new(["foo", "bar"]).reverse() // ["bar", "foo"] * // Bool8Series * Series.new([false, true]).reverse() // [true, false] * ``` */ reverse(memoryResource?: MemoryResource): Series; /** * @summary Return sub-selection from a Series using the specified integral indices. * * @description Gathers the rows of the source columns according to `selection`, such that row "i" * in the resulting Series's columns will contain row `selection[i]` from the source columns. The * number of rows in the result series will be equal to the number of elements in selection. A * negative value i in the selection is interpreted as i+n, where `n` is the number of rows in * the source series. * * For dictionary columns, the keys column component is copied and not trimmed if the gather * results in abandoned key elements. * * @param indices A Series of 8/16/32-bit signed or unsigned integer indices to gather. * @param nullify_out_of_bounds If `true`, coerce rows that corresponds to out-of-bounds indices * in the selection to null. If `false`, skips all bounds checking for selection values. Pass * false if you are certain that the selection contains only valid indices for better * performance. If `false` and there are out-of-bounds indices in the selection, the behavior * is undefined. Defaults to `false`. * @param memoryResource An optional MemoryResource used to allocate the result's device memory. * * @example * ```typescript * import {Series, Int32} from '@rapidsai/cudf'; * * const a = Series.new([1,2,3]); * const b = Series.new(["foo", "bar", "test"]); * const c = Series.new([true, false, true]); * const selection = Series.new({type: new Int32, data: [0,2]}); * * a.gather(selection) // Float64Series [1,3] * b.gather(selection) // StringSeries ["foo", "test"] * c.gather(selection) // Bool8Series [true, true] * ``` */ gather(indices: Series | number[], nullify_out_of_bounds?: boolean, memoryResource?: MemoryResource): Series; /** * Return a copy of this Series. * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * const a = Series.new(["foo", "bar", "test"]); * * a.copy() // StringSeries ["foo", "bar", "test"] * ``` */ copy(memoryResource?: MemoryResource): Series; /** * Returns the n largest element(s). * * @param n The number of values to retrieve. * @param keep Determines whether to keep the first or last of any duplicate values. * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * const a = Series.new([4, 6, 8, 10, 12, 1, 2]); * const b = Series.new(["foo", "bar", "test"]); * * a.nLargest(); // [12, 10, 8, 6, 4] * b.nLargest(1); // ["test"] * a.nLargest(-1); // [] * ``` */ nLargest(n?: number, keep?: keyof typeof DuplicateKeepOption): Series; /** * Returns the n smallest element(s). * * @param n The number of values to retrieve. * @param keep Determines whether to keep the first or last of any duplicate values. * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * const a = Series.new([4, 6, 8, 10, 12, 1, 2]); * const b = Series.new(["foo", "bar", "test"]); * * a.nSmallest(); // [1, 2, 4, 6, 8] * b.nSmallest(1); // ["bar"] * a.nSmallest(-1); // [] * ``` */ nSmallest(n?: number, keep?: keyof typeof DuplicateKeepOption): Series; /** * Returns the first n rows. * * @param n The number of rows to return. * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * const a = Series.new([4, 6, 8, 10, 12, 1, 2]); * const b = Series.new(["foo", "bar", "test"]); * * a.head(); // [4, 6, 8, 10, 12] * b.head(1); // ["foo"] * a.head(-1); // throws index out of bounds error * ``` */ head(n?: number): Series; /** * Returns the last n rows. * * @param n The number of rows to return. * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * const a = Series.new([4, 6, 8, 10, 12, 1, 2]); * const b = Series.new(["foo", "bar", "test"]); * * a.tail(); // [8, 10, 12, 1, 2] * b.tail(1); // ["test"] * a.tail(-1); // throws index out of bounds error * ``` */ tail(n?: number): Series; /** * Scatters single value into this Series according to provided indices. * * @param value A column of values to be scattered in to this Series * @param indices A column of integral indices that indicate the rows in the this Series to be * replaced by `value`. * @param memoryResource An optional MemoryResource used to allocate the result's device memory. * * @example * ```typescript * import {Series, Int32} from '@rapidsai/cudf'; * const a = Series.new({type: new Int32, data: [0, 1, 2, 3, 4]}); * const indices = Series.new({type: new Int32, data: [2, 4]}); * const indices_out_of_bounds = Series.new({type: new Int32, data: [5, 6]}); * * a.scatter(-1, indices); // returns [0, 1, -1, 3, -1]; * a.scatter(-1, indices_out_of_bounds, true) // throws index out of bounds error * * ``` */ scatter(value: T['scalarType'], indices: Series | number[], memoryResource?: MemoryResource): Series; /** * Scatters a column of values into this Series according to provided indices. * * @param value A value to be scattered in to this Series * @param indices A column of integral indices that indicate the rows in the this Series to be * replaced by `value`. * @param memoryResource An optional MemoryResource used to allocate the result's device memory. * * @example * ```typescript * import {Series, Int32} from '@rapidsai/cudf'; * const a = Series.new({type: new Int32, data: [0, 1, 2, 3, 4]}); * const b = Series.new({type: new Int32, data: [200, 400]}); * const indices = Series.new({type: new Int32, data: [2, 4]}); * const indices_out_of_bounds = Series.new({type: new Int32, data: [5, 6]}); * * a.scatter(b, indices); // returns [0, 1, 200, 3, 400]; * a.scatter(b, indices_out_of_bounds, true) // throws index out of bounds error * ``` */ scatter(values: Series, indices: Series | number[], memoryResource?: MemoryResource): Series; /** * Return a sub-selection of this Series using the specified boolean mask. * * @param mask A Series of boolean values for whose corresponding element in this Series * will be selected or ignored. * @param memoryResource An optional MemoryResource used to allocate the result's device memory. * * @example * ```typescript * import {Series} from "@rapidsai/cudf"; * const mask = Series.new([true, false, true]); * * // Float64Series * Series.new([1, 2, 3]).filter(mask) // [1, 3] * // StringSeries * Series.new(["foo", "bar", "test"]).filter(mask) // ["foo", "test"] * // Bool8Series * Series.new([false, true, true]).filter(mask) // [false, true] * ``` */ filter(mask: Series, memoryResource?: MemoryResource): Series; /** * set values at the specified indices * * @param indices the indices in this Series to set values for * @param values the values to set at Series of indices * * @example * ```typescript * import {Series, Int32} from '@rapidsai/cudf'; * const a = Series.new({type: new Int32, data: [0, 1, 2, 3, 4]}); * const values = Series.new({type: new Int32, data: [200, 400]}); * const indices = Series.new({type: new Int32, data: [2, 4]}); * * a.setValues(indices, values); // inplace update [0, 1, 200, 3, 400]; * a.setValues(indices, -1); // inplace update [0, 1, -1, 3, -1]; * ``` */ setValues(indices: Series | number[], values: Series | T['scalarType']): void; /** * Copy the underlying device memory to host, and return an Iterator of the values. */ [Symbol.iterator](): IterableIterator; /** * Copy the underlying device memory to host and return an Array (or TypedArray) of the values. * @returns */ toArray(): T["TArray"]; /** * Return a string with a tabular representation of the Series, pretty-printed according to the * options given. * * @param options */ toString(options?: DisplayOptions & { name?: string; }): string; /** * * @param mask The null-mask. Valid values are marked as 1; otherwise 0. The * mask bit given the data index idx is computed as: * ``` * (mask[idx // 8] >> (idx % 8)) & 1 * ``` * @param nullCount The number of null values. If None, it is calculated * automatically. */ setNullMask(mask: MemoryData | ArrayLike | ArrayLike, nullCount?: number): void; /** * Copy a Series to an Arrow vector in host memory */ toArrow(): arrow.Vector; /** * Generate an ordering that sorts the Series in a specified way. * * @param ascending whether to sort ascending (true) or descending (false) * @param null_order whether nulls should sort before or after other values * @param memoryResource An optional MemoryResource used to allocate the result's device memory. * * @returns Series containting the permutation indices for the desired sort order * * @example * ```typescript * import {Series, NullOrder} from '@rapidsai/cudf'; * * // Float64Series * Series.new([50, 40, 30, 20, 10, 0]).orderBy(false) // [0, 1, 2, 3, 4, 5] * Series.new([50, 40, 30, 20, 10, 0]).orderBy(true) // [5, 4, 3, 2, 1, 0] * * // StringSeries * Series.new(["a", "b", "c", "d", "e"]).orderBy(false) // [4, 3, 2, 1, 0] * Series.new(["a", "b", "c", "d", "e"]).orderBy(true) // [0, 1, 2, 3, 4] * * // Bool8Series * Series.new([true, false, true, true, false]).orderBy(true) // [1, 4, 0, 2, 3] * Series.new([true, false, true, true, false]).orderBy(false) // [0, 2, 3, 1, 4] * * // NullOrder usage * Series.new([50, 40, 30, 20, 10, null]).orderBy(false, 'before') // [0, 1, 2, 3, 4, 5] * Series.new([50, 40, 30, 20, 10, null]).orderBy(false, 'after') // [5, 0, 1, 2, 3, 4] * ``` */ orderBy(ascending?: boolean, null_order?: keyof typeof NullOrder, memoryResource?: MemoryResource): Int32Series; /** * Generate a new Series that is sorted in a specified way. * * @param ascending whether to sort ascending (true) or descending (false) * Default: true * @param null_order whether nulls should sort before or after other values * Default: before * @param memoryResource An optional MemoryResource used to allocate the result's device memory. * * @returns Sorted values * * @example * ```typescript * import {Series, NullOrder} from '@rapidsai/cudf'; * * // Float64Series * Series.new([50, 40, 30, 20, 10, 0]).sortValues(false) // [50, 40, 30, 20, 10, 0] * Series.new([50, 40, 30, 20, 10, 0]).sortValues(true) // [0, 10, 20, 30, 40, 50] * * // StringSeries * Series.new(["a", "b", "c", "d", "e"]).sortValues(false) // ["e", "d", "c", "b", "a"] * Series.new(["a", "b", "c", "d", "e"]).sortValues(true) // ["a", "b", "c", "d", "e"] * * // Bool8Series * Series.new([true, false, true, true, false]).sortValues(true) // [false, false, true, * true, true] Series.new([true, false, true, true, false]).sortValues(false) // [true, * true, true, false, false] * * // NullOrder usage * Series.new([50, 40, 30, 20, 10, null]).sortValues(false, 'before') // [50, 40, 30, 20, * 10, null] * * Series.new([50, 40, 30, 20, 10, null]).sortValues(false, 'after') // [null, 50, 40, 30, * 20, 10] * ``` */ sortValues(ascending?: boolean, null_order?: keyof typeof NullOrder, memoryResource?: MemoryResource): Series; /** * Creates a Series of `BOOL8` elements where `true` indicates the value is null and `false` * indicates the value is valid. * * @param memoryResource Memory resource used to allocate the result Column's device memory. * @returns A non-nullable Series of `BOOL8` elements with `true` representing `null` * values. * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * // Float64Series * Series.new([1, null, 3]).isNull() // [false, true, false] * // StringSeries * Series.new(["foo", "bar", null]).isNull() // [false, false, true] * // Bool8Series * Series.new([true, true, null]).isNull() // [false, false, true] * ``` */ isNull(memoryResource?: MemoryResource): Bool8Series; /** * Creates a Series of `BOOL8` elements where `true` indicates the value is valid and * `false` indicates the value is null. * * @param memoryResource Memory resource used to allocate the result Column's device memory. * @returns A non-nullable Series of `BOOL8` elements with `false` representing `null` * values. * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * // Float64Series * Series.new([1, null, 3]).isNotNull() // [true, false, true] * // StringSeries * Series.new(["foo", "bar", null]).isNotNull() // [true, true, false] * // Bool8Series * Series.new([true, true, null]).isNotNull() // [true, true, false] * ``` */ isNotNull(memoryResource?: MemoryResource): Bool8Series; /** * drop Null values from the series * @param memoryResource Memory resource used to allocate the result Column's device memory. * @returns series without Null values * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * // Float64Series * Series.new([1, undefined, 3]).dropNulls() // [1, 3] * Series.new([1, null, 3]).dropNulls() // [1, 3] * Series.new([1, , 3]).dropNulls() // [1, 3] * * // StringSeries * Series.new(["foo", "bar", undefined]).dropNulls() // ["foo", "bar"] * Series.new(["foo", "bar", null]).dropNulls() // ["foo", "bar"] * Series.new(["foo", "bar", ,]).dropNulls() // ["foo", "bar"] * * // Bool8Series * Series.new([true, true, undefined]).dropNulls() // [true, true] * Series.new([true, true, null]).dropNulls() // [true, true] * Series.new([true, true, ,]).dropNulls() // [true, true] * ``` */ dropNulls(memoryResource?: MemoryResource): Series; /** * @summary Hook for specialized Series to override when constructing from a C++ Column. */ protected __construct(col: Column): Series; /** * Returns an object with keys "value" and "count" whose respective values are new Series * containing the unique values in the original series and the number of times they occur * in the original series. * @returns object with keys "value" and "count" */ valueCounts(): { count: Int32Series; value: Series; }; /** * Returns a new Series with only the unique values that were found in the original * * @param nullsEqual Determines whether nulls are handled as equal values. * @param memoryResource Memory resource used to allocate the result Column's device memory. * @returns series without duplicate values * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * // Float64Series * Series.new([null, null, 1, 2, 3, 3]).unique(true) // [null, 1, 2, 3] * Series.new([null, null, 1, 2, 3, 3]).unique(false) // [null, null, 1, 2, 3] * ``` */ unique(nullsEqual?: boolean, memoryResource?: MemoryResource): Series; /** * Returns a new Series with duplicate values from the original removed * * @param keep Determines whether or not to keep the duplicate items. * @param nullsEqual Determines whether nulls are handled as equal values. * @param nullsFirst Determines whether null values are inserted before or after non-null * values. * @param memoryResource Memory resource used to allocate the result Column's device memory. * @returns series without duplicate values * * @example * ```typescript * import {Series} from '@rapidsai/cudf'; * * // Float64Series * Series.new([4, null, 1, 2, null, 3, 4]).dropDuplicates( * true, * true, * true * ) // [null, 1, 2, 3, 4] * * Series.new([4, null, 1, 2, null, 3, 4]).dropDuplicates( * false, * true, * true * ) // [1, 2, 3] * ``` */ dropDuplicates(keep?: boolean, nullsEqual?: boolean, nullsFirst?: boolean, memoryResource?: MemoryResource): Series; } export declare const Series: typeof AbstractSeries; import { Bool8Series } from './series/bool'; import { CategoricalSeries } from './series/categorical'; import { Float32Series, Float64Series } from './series/float'; import { Int8Series, Int16Series, Int32Series, Uint8Series, Uint16Series, Uint32Series, Int64Series, Uint64Series } from './series/integral'; import { StringSeries } from './series/string'; import { ListSeries } from './series/list'; import { StructSeries } from './series/struct'; import { TimestampDaySeries, TimestampMicrosecondSeries, TimestampMillisecondSeries, TimestampNanosecondSeries, TimestampSecondSeries } from './series/timestamp'; export { Bool8Series, Float32Series, Float64Series, Int8Series, Int16Series, Int32Series, Uint8Series, Uint16Series, Uint32Series, Int64Series, Uint64Series, StringSeries, ListSeries, StructSeries, }; //# sourceMappingURL=series.d.ts.map