Series#

Constructor#

cudf.Series([data, index, dtype, name, copy, ...])

One-dimensional GPU array (including time series).

Attributes#

Axes

Series.axes

Return a list representing the axes of the Series.

Series.index

Get the labels for the rows.

Series.values

Return a CuPy representation of the DataFrame.

Series.data

The gpu buffer for the data

Series.dtype

The dtype of the Series.

Series.shape

Get a tuple representing the dimensionality of the Index.

Series.ndim

Number of dimensions of the underlying data, by definition 1.

Series.nullable

A boolean indicating whether a null-mask is needed

Series.nullmask

The gpu buffer for the null-mask

Series.null_count

Number of null values

Series.size

Return the number of elements in the underlying data.

Series.T

Return the transpose, which is by definition self.

Series.memory_usage([index, deep])

Return the memory usage of an object.

Series.hasnans

Return True if there are any NaNs or nulls.

Series.has_nulls

Indicator whether Series contains null values.

Series.empty

Indicator whether DataFrame or Series is empty.

Series.name

Get the name of this object.

Series.valid_count

Number of non-null values

Series.values_host

Return a NumPy representation of the data.

Conversion#

Series.astype(dtype[, copy, errors])

Cast the object to the given dtype.

Series.convert_dtypes([infer_objects, ...])

Convert columns to the best possible nullable dtypes.

Series.copy([deep])

Make a copy of this object's indices and data.

Series.deserialize(header, frames)

Generate an object from a serialized representation.

Series.device_deserialize(header, frames)

Perform device-side deserialization tasks.

Series.device_serialize()

Serialize data and metadata associated with device memory.

Series.host_deserialize(header, frames)

Perform device-side deserialization tasks.

Series.host_serialize()

Serialize data and metadata associated with host memory.

Series.serialize()

Generate an equivalent serializable representation of an object.

Series.to_list()

Series.tolist()

Series.__array__([dtype])

Series.scale()

Scale values to [0, 1] in float64

Indexing, iteration#

Series.loc

Select rows and columns by label or boolean mask.

Series.iloc

Select values by position.

Series.__iter__()

Iteration is unsupported.

Series.items()

Iteration is unsupported.

Series.iteritems()

Iteration is unsupported.

Series.keys()

Return alias for index.

Series.squeeze([axis])

Squeeze 1 dimensional axis objects into scalars.

Binary operator functions#

Series.add(other[, level, fill_value, axis])

Get Addition of DataFrame or Series and other, element-wise (binary operator add).

Series.sub(other[, level, fill_value, axis])

Get Subtraction of DataFrame or Series and other, element-wise (binary operator sub).

Series.subtract(other[, level, fill_value, axis])

Get Subtraction of DataFrame or Series and other, element-wise (binary operator sub).

Series.mul(other[, level, fill_value, axis])

Get Multiplication of DataFrame or Series and other, element-wise (binary operator mul).

Series.multiply(other[, level, fill_value, axis])

Get Multiplication of DataFrame or Series and other, element-wise (binary operator mul).

Series.truediv(other[, level, fill_value, axis])

Get Floating division of DataFrame or Series and other, element-wise (binary operator truediv).

Series.div(other[, level, fill_value, axis])

Get Floating division of DataFrame or Series and other, element-wise (binary operator truediv).

Series.divide(other[, level, fill_value, axis])

Get Floating division of DataFrame or Series and other, element-wise (binary operator truediv).

Series.floordiv(other[, level, fill_value, axis])

Get Integer division of DataFrame or Series and other, element-wise (binary operator floordiv).

Series.mod(other[, level, fill_value, axis])

Get Modulo of DataFrame or Series and other, element-wise (binary operator mod).

Series.pow(other[, level, fill_value, axis])

Get Exponential of DataFrame or Series and other, element-wise (binary operator pow).

Series.radd(other[, level, fill_value, axis])

Get Addition of DataFrame or Series and other, element-wise (binary operator radd).

Series.rsub(other[, level, fill_value, axis])

Get Subtraction of DataFrame or Series and other, element-wise (binary operator rsub).

Series.rmul(other[, level, fill_value, axis])

Get Multiplication of DataFrame or Series and other, element-wise (binary operator rmul).

Series.rdiv(other[, level, fill_value, axis])

Get Floating division of DataFrame or Series and other, element-wise (binary operator rtruediv).

Series.rtruediv(other[, level, fill_value, axis])

Get Floating division of DataFrame or Series and other, element-wise (binary operator rtruediv).

Series.rfloordiv(other[, level, fill_value, ...])

Get Integer division of DataFrame or Series and other, element-wise (binary operator rfloordiv).

Series.rmod(other[, level, fill_value, axis])

Get Modulo of DataFrame or Series and other, element-wise (binary operator rmod).

Series.rpow(other[, level, fill_value, axis])

Get Exponential of DataFrame or Series and other, element-wise (binary operator rpow).

Series.round([decimals, how])

Round to a variable number of decimal places.

Series.lt(other[, level, fill_value, axis])

Get Less than of DataFrame or Series and other, element-wise (binary operator lt).

Series.gt(other[, level, fill_value, axis])

Get Greater than of DataFrame or Series and other, element-wise (binary operator gt).

Series.le(other[, level, fill_value, axis])

Get Less than or equal to of DataFrame or Series and other, element-wise (binary operator le).

Series.ge(other[, level, fill_value, axis])

Get Greater than or equal to of DataFrame or Series and other, element-wise (binary operator ge).

Series.ne(other[, level, fill_value, axis])

Get Not equal to of DataFrame or Series and other, element-wise (binary operator ne).

Series.eq(other[, level, fill_value, axis])

Get Equal to of DataFrame or Series and other, element-wise (binary operator eq).

Series.product([axis, skipna, dtype, ...])

Return product of the values in the DataFrame.

Series.dot(other[, reflect])

Get dot product of frame and other, (binary operator dot).

Function application, GroupBy & window#

Series.apply(func[, convert_dtype, args])

Apply a scalar function to the values of a Series.

Series.map(arg[, na_action])

Map values of Series according to input correspondence.

Series.groupby([by, axis, level, as_index, ...])

Group using a mapper or by a Series of columns.

Series.rolling(window[, min_periods, ...])

Rolling window calculations.

Series.pipe(func, *args, **kwargs)

Apply func(self, *args, **kwargs).

Computations / descriptive stats#

Series.abs()

Return a Series/DataFrame with absolute numeric value of each element.

Series.all([axis, bool_only, skipna])

Return whether all elements are True in DataFrame.

Series.any([axis, bool_only, skipna])

Return whether any elements is True in DataFrame.

Series.autocorr([lag])

Compute the lag-N autocorrelation.

Series.between(left, right[, inclusive])

Return boolean Series equivalent to left <= series <= right.

Series.clip([lower, upper, inplace, axis])

Trim values at input threshold(s).

Series.corr(other[, method, min_periods])

Calculates the sample correlation between two Series, excluding missing values.

Series.count()

Return number of non-NA/null observations in the Series

Series.cov(other[, min_periods])

Compute covariance with Series, excluding missing values.

Series.cummax([axis, skipna])

Return cumulative max of the Series.

Series.cummin([axis, skipna])

Return cumulative min of the Series.

Series.cumprod([axis, skipna])

Return cumulative product of the Series.

Series.cumsum([axis, skipna])

Return cumulative sum of the Series.

Series.describe([percentiles, include, exclude])

Generate descriptive statistics.

Series.diff([periods])

First discrete difference of element.

Series.digitize(bins[, right])

Return the indices of the bins to which each value belongs.

Series.factorize([sort, use_na_sentinel])

Encode the input values as integer labels.

Series.kurt([axis, skipna, numeric_only])

Return Fisher's unbiased kurtosis of a sample.

Series.max([axis, skipna, numeric_only])

Return the maximum of the values in the DataFrame.

Series.mean([axis, skipna, numeric_only])

Return the mean of the values for the requested axis.

Series.median([axis, skipna, level, ...])

Return the median of the values for the requested axis.

Series.min([axis, skipna, numeric_only])

Return the minimum of the values in the DataFrame.

Series.mode([dropna])

Return the mode(s) of the dataset.

Series.nlargest([n, keep])

Returns a new Series of the n largest element.

Series.nsmallest([n, keep])

Returns a new Series of the n smallest element.

Series.pct_change([periods, fill_method, ...])

Calculates the percent change between sequential elements in the Series.

Series.prod([axis, skipna, dtype, ...])

Return product of the values in the DataFrame.

Series.quantile([q, interpolation, exact, ...])

Return values at the given quantile.

Series.rank([axis, method, numeric_only, ...])

Compute numerical data ranks (1 through n) along axis.

Series.skew([axis, skipna, numeric_only])

Return unbiased Fisher-Pearson skew of a sample.

Series.std([axis, skipna, ddof, numeric_only])

Return sample standard deviation of the DataFrame.

Series.sum([axis, skipna, dtype, ...])

Return sum of the values in the DataFrame.

Series.var([axis, skipna, ddof, numeric_only])

Return unbiased variance of the DataFrame.

Series.kurtosis([axis, skipna, numeric_only])

Return Fisher's unbiased kurtosis of a sample.

Series.unique()

Returns unique values of this Series.

Series.nunique([dropna])

Return count of unique values for the column.

Series.is_unique

Return boolean if values in the object are unique.

Series.is_monotonic_increasing

Return boolean if values in the object are monotonically increasing.

Series.is_monotonic_decreasing

Return boolean if values in the object are monotonically decreasing.

Series.value_counts([normalize, sort, ...])

Return a Series containing counts of unique values.

Reindexing / selection / label manipulation#

Series.add_prefix(prefix)

Prefix labels with string prefix.

Series.add_suffix(suffix)

Suffix labels with string suffix.

Series.drop([labels, axis, index, columns, ...])

Drop specified labels from rows or columns.

Series.drop_duplicates([keep, inplace, ...])

Return Series with duplicate values removed.

Series.duplicated([keep])

Indicate duplicate Series values.

Series.equals(other)

Test whether two objects contain the same elements.

Series.first(offset)

Select initial periods of time series data based on a date offset.

Series.head([n])

Return the first n rows.

Series.isin(values)

Check whether values are contained in Series.

Series.last(offset)

Select final periods of time series data based on a date offset.

Series.reindex(*args, **kwargs)

Conform Series to new index.

Series.rename([index, copy])

Alter Series name

Series.reset_index([level, drop, name, inplace])

Reset the index of the Series, or a level of it.

Series.sample([n, frac, replace, weights, ...])

Return a random sample of items from an axis of object.

Series.take(indices[, axis])

Return a new frame containing the rows specified by indices.

Series.tail([n])

Returns the last n rows as a new DataFrame or Series

Series.tile(count)

Repeats the rows count times to form a new Frame.

Series.truncate([before, after, axis, copy])

Truncate a Series or DataFrame before and after some index value.

Series.where(cond[, other, inplace])

Replace values where the condition is False.

Series.mask(cond[, other, inplace])

Replace values where the condition is True.

Missing data handling#

Series.backfill([value, axis, inplace, limit])

Synonym for Series.fillna() with method='bfill'.

Series.bfill([value, axis, inplace, limit])

Synonym for Series.fillna() with method='bfill'.

Series.dropna([axis, inplace, how])

Return a Series with null values removed.

Series.ffill([value, axis, inplace, limit])

Synonym for Series.fillna() with method='ffill'.

Series.fillna([value, method, axis, ...])

Fill null values with value or specified method.

Series.interpolate([method, axis, limit, ...])

Interpolate data values between some points.

Series.isna()

Identify missing values.

Series.isnull()

Identify missing values.

Series.nans_to_nulls()

Convert nans (if any) to nulls

Series.notna()

Identify non-missing values.

Series.notnull()

Identify non-missing values.

Series.pad([value, axis, inplace, limit])

Synonym for Series.fillna() with method='ffill'.

Series.replace([to_replace, value])

Replace values given in to_replace with value.

Reshaping, sorting#

Series.argsort([axis, kind, order, ...])

Return the integer indices that would sort the Series values.

Series.sort_values([axis, ascending, ...])

Sort by the values along either axis.

Series.sort_index([axis])

Sort object by labels (along an axis).

Series.explode([ignore_index])

Transform each element of a list-like to a row, replicating index values.

Series.searchsorted(values[, side, ...])

Find indices where elements should be inserted to maintain order

Series.repeat(repeats[, axis])

Repeats elements consecutively.

Series.transpose()

Return the transpose, which is by definition self.

Combining / comparing / joining / merging#

Series.update(other)

Modify Series in place using values from passed Series.

Accessors#

pandas provides dtype-specific methods under various accessors. These are separate namespaces within Series that only apply to specific data types.

Data Type

Accessor

Datetime, Timedelta

dt

String

str

Categorical

cat

List

list

Struct

struct

Datetimelike properties#

Series.dt can be used to access the values of the series as datetimelike and return several properties. These can be accessed like Series.dt.<property>.

Series.dt

Accessor object for datetime-like properties of the Series values.

Datetime properties#

year

The year of the datetime.

month

The month as January=1, December=12.

day

The day of the datetime.

hour

The hours of the datetime.

minute

The minutes of the datetime.

second

The seconds of the datetime.

microsecond

The microseconds of the datetime.

nanosecond

The nanoseconds of the datetime.

dayofweek

The day of the week with Monday=0, Sunday=6.

weekday

The day of the week with Monday=0, Sunday=6.

dayofyear

The day of the year, from 1-365 in non-leap years and from 1-366 in leap years.

day_of_year

The day of the year, from 1-365 in non-leap years and from 1-366 in leap years.

quarter

Integer indicator for which quarter of the year the date belongs in.

is_month_start

Booleans indicating if dates are the first day of the month.

is_month_end

Boolean indicator if the date is the last day of the month.

is_quarter_start

Boolean indicator if the date is the first day of a quarter.

is_quarter_end

Boolean indicator if the date is the last day of a quarter.

is_year_start

Boolean indicator if the date is the first day of the year.

is_year_end

Boolean indicator if the date is the last day of the year.

is_leap_year

Boolean indicator if the date belongs to a leap year.

days_in_month

Get the total number of days in the month that the date falls on.

Datetime methods#

isocalendar()

Returns a DataFrame with the year, week, and day calculated according to the ISO 8601 standard.

strftime(date_format, *args, **kwargs)

Convert to Series using specified date_format.

round(freq)

Perform round operation on the data to the specified freq.

floor(freq)

Perform floor operation on the data to the specified freq.

ceil(freq)

Perform ceil operation on the data to the specified freq.

tz_localize(tz[, ambiguous, nonexistent])

Localize timezone-naive data to timezone-aware data.

Timedelta properties#

days

Number of days.

seconds

Number of seconds (>= 0 and less than 1 day).

microseconds

Number of microseconds (>= 0 and less than 1 second).

nanoseconds

Return the number of nanoseconds (n), where 0 <= n < 1 microsecond.

components

Return a Dataframe of the components of the Timedeltas.

String handling#

Series.str can be used to access the values of the series as strings and apply several methods to it. These can be accessed like Series.str.<function/property>.

Series.str

Vectorized string functions for Series and Index.

byte_count()

Computes the number of bytes of each string in the Series/Index.

capitalize()

Convert strings in the Series/Index to be capitalized.

cat()

Concatenate strings in the Series/Index with given separator.

center(width[, fillchar])

Filling left and right side of strings in the Series/Index with an additional character.

character_ngrams([n, as_list])

Generate the n-grams from characters in a column of strings.

character_tokenize()

Each string is split into individual characters.

code_points()

Returns an array by filling it with the UTF-8 code point values for each character of each string.

contains(pat[, case, flags, na, regex])

Test if pattern or regex is contained within a string of a Series or Index.

count(pat[, flags])

Count occurrences of pattern in each string of the Series/Index.

detokenize(indices[, separator])

Combines tokens into strings by concatenating them in the order in which they appear in the indices column.

edit_distance(targets)

The targets strings are measured against the strings in this instance using the Levenshtein edit distance algorithm.

edit_distance_matrix()

Computes the edit distance between strings in the series.

endswith(pat)

Test if the end of each string element matches a pattern.

extract(pat[, flags, expand])

Extract capture groups in the regex pat as columns in a DataFrame.

filter_alphanum([repl, keep])

Remove non-alphanumeric characters from strings in this column.

filter_characters(table[, keep, repl])

Remove characters from each string using the character ranges in the given mapping table.

filter_tokens(min_token_length[, ...])

Remove tokens from within each string in the series that are smaller than min_token_length and optionally replace them with the replacement string.

find(sub[, start, end])

Return lowest indexes in each strings in the Series/Index where the substring is fully contained between [start:end].

findall(pat[, flags])

Find all occurrences of pattern or regular expression in the Series/Index.

find_multiple(patterns)

Find all first occurrences of patterns in the Series/Index.

get([i])

Extract element from each component at specified position.

get_json_object(json_path, *[, ...])

Applies a JSONPath string to an input strings column where each row in the column is a valid json string

hex_to_int()

Returns integer value represented by each hex string.

htoi()

Returns integer value represented by each hex string.

index(sub[, start, end])

Return lowest indexes in each strings where the substring is fully contained between [start:end].

insert([start, repl])

Insert the specified string into each string in the specified position.

ip2int()

This converts ip strings to integers

ip_to_int()

This converts ip strings to integers

is_consonant(position)

Return true for strings where the character at position is a consonant.

is_vowel(position)

Return true for strings where the character at position is a vowel -- not a consonant.

isalnum()

Check whether all characters in each string are alphanumeric.

isalpha()

Check whether all characters in each string are alphabetic.

isdecimal()

Check whether all characters in each string are decimal.

isdigit()

Check whether all characters in each string are digits.

isempty()

Check whether each string is an empty string.

isfloat()

Check whether all characters in each string form floating value.

ishex()

Check whether all characters in each string form a hex integer.

isinteger()

Check whether all characters in each string form integer.

isipv4()

Check whether all characters in each string form an IPv4 address.

isspace()

Check whether all characters in each string are whitespace.

islower()

Check whether all characters in each string are lowercase.

isnumeric()

Check whether all characters in each string are numeric.

isupper()

Check whether all characters in each string are uppercase.

istimestamp(format)

Check whether all characters in each string can be converted to a timestamp using the given format.

istitle()

Check whether each string is title formatted.

join([sep, string_na_rep, sep_na_rep])

Join lists contained as elements in the Series/Index with passed delimiter.

len()

Computes the length of each element in the Series/Index.

like(pat[, esc])

Test if a like pattern matches a string of a Series or Index.

ljust(width[, fillchar])

Filling right side of strings in the Series/Index with an additional character.

lower()

Converts all characters to lowercase.

lstrip([to_strip])

Remove leading and trailing characters.

match(pat[, case, flags])

Determine if each string matches a regular expression.

ngrams([n, separator])

Generate the n-grams from a set of tokens, each record in series is treated a token.

ngrams_tokenize([n, delimiter, separator])

Generate the n-grams using tokens from each string.

normalize_characters([do_lower])

Normalizes strings characters for tokenizing.

normalize_spaces()

Remove extra whitespace between tokens and trim whitespace from the beginning and the end of each string.

pad(width[, side, fillchar])

Pad strings in the Series/Index up to width.

partition([sep, expand])

Split the string at the first occurrence of sep.

porter_stemmer_measure()

Compute the Porter Stemmer measure for each string.

repeat(repeats)

Duplicate each string in the Series or Index.

removeprefix(prefix)

Remove a prefix from an object series.

removesuffix(suffix)

Remove a suffix from an object series.

replace(pat, repl[, n, case, flags, regex])

Replace occurrences of pattern/regex in the Series/Index with some other string.

replace_tokens(targets, replacements[, ...])

The targets tokens are searched for within each string in the series and replaced with the corresponding replacements if found.

replace_with_backrefs(pat, repl)

Use the repl back-ref template to create a new string with the extracted elements found using the pat expression.

rfind(sub[, start, end])

Return highest indexes in each strings in the Series/Index where the substring is fully contained between [start:end].

rindex(sub[, start, end])

Return highest indexes in each strings where the substring is fully contained between [start:end].

rjust(width[, fillchar])

Filling left side of strings in the Series/Index with an additional character.

rpartition([sep, expand])

Split the string at the last occurrence of sep.

rsplit([pat, n, expand, regex])

Split strings around given separator/delimiter.

rstrip([to_strip])

Remove leading and trailing characters.

slice([start, stop, step])

Slice substrings from each element in the Series or Index.

slice_from(starts, stops)

Return substring of each string using positions for each string.

slice_replace([start, stop, repl])

Replace the specified section of each string with a new string.

split([pat, n, expand, regex])

Split strings around given separator/delimiter.

rsplit([pat, n, expand, regex])

Split strings around given separator/delimiter.

startswith(pat)

Test if the start of each string element matches a pattern.

strip([to_strip])

Remove leading and trailing characters.

swapcase()

Change each lowercase character to uppercase and vice versa.

title()

Uppercase the first letter of each letter after a space and lowercase the rest.

token_count([delimiter])

Each string is split into tokens using the provided delimiter.

tokenize([delimiter])

Each string is split into tokens using the provided delimiter(s).

translate(table)

Map all characters in the string through the given mapping table.

upper()

Convert each string to uppercase.

url_decode()

Returns a URL-decoded format of each string.

url_encode()

Returns a URL-encoded format of each string.

wrap(width, **kwargs)

Wrap long strings in the Series/Index to be formatted in paragraphs with length less than a given width.

zfill(width)

Pad strings in the Series/Index by prepending '0' characters.

Categorical accessor#

Categorical-dtype specific methods and attributes are available under the Series.cat accessor.

Series.cat

Accessor object for categorical properties of the Series values.

categories

The categories of this categorical.

ordered

Whether the categories have an ordered relationship.

codes

Return Series of codes as well as the index.

reorder_categories(new_categories[, ordered])

Reorder categories as specified in new_categories.

add_categories(new_categories)

Add new categories.

remove_categories(removals)

Remove the specified categories.

set_categories(new_categories[, ordered, rename])

Set the categories to the specified new_categories.

as_ordered()

Set the Categorical to be ordered.

as_unordered()

Set the Categorical to be unordered.

List handling#

Series.list can be used to access the values of the series as lists and apply list methods to it. These can be accessed like Series.list.<function/property>.

Series.list

List methods for Series

astype(dtype)

Return a new list Series with the leaf values casted to the specified data type.

concat([dropna])

For a column with at least one level of nesting, concatenate the lists in each row.

contains(search_key)

Returns boolean values indicating whether the specified scalar is an element of each row.

index(search_key)

Returns integers representing the index of the search key for each row.

get(index[, default])

Extract element at the given index from each list in a Series of lists.

leaves

From a Series of (possibly nested) lists, obtain the elements from the innermost lists as a flat Series (one value per row).

len()

Computes the length of each element in the Series/Index.

sort_values([ascending, inplace, kind, ...])

Sort each list by the values.

take(lists_indices)

Collect list elements based on given indices.

unique()

Returns the unique elements in each list.

Struct handling#

Series.struct can be used to access the values of the series as Structs and apply struct methods to it. These can be accessed like Series.struct.<function/property>.

Series.struct

Struct methods for Series

field(key)

Extract children of the specified struct column in the Series

explode()

Return a DataFrame whose columns are the fields of this struct Series.

Serialization / IO / conversion#

Series.to_arrow()

Convert to a PyArrow Array.

Series.to_cupy([dtype, copy, na_value])

Convert the Frame to a CuPy array.

Series.to_dict([into])

Convert Series to {label -> value} dict or dict-like object.

Series.to_dlpack()

Converts a cuDF object into a DLPack tensor.

Series.to_frame([name])

Convert Series into a DataFrame

Series.to_hdf(path_or_buf, key, *args, **kwargs)

Write the contained data to an HDF5 file using HDFStore.

Series.to_json([path_or_buf])

Convert the cuDF object to a JSON string.

Series.to_numpy([dtype, copy, na_value])

Convert the Frame to a NumPy array.

Series.to_pandas(*[, index, nullable, ...])

Convert to a pandas Series.

Series.to_string()

Convert to string

Series.from_arrow(array)

Create from PyArrow Array/ChunkedArray.

Series.from_categorical(categorical[, codes])

Creates from a pandas.Categorical

Series.from_masked_array(data, mask[, ...])

Create a Series with null-mask.

Series.from_pandas(s[, nan_as_null])

Convert from a Pandas Series.

Series.hash_values([method, seed])

Compute the hash of values in this column.