Overview
A Series is a one-dimensional labeled array that can hold any data type. It is similar to a column in a spreadsheet or database table, combining:- An array of data values
- An array of index labels (can be strings or numbers)
- An optional name
Constructor
Array of values to store in the Series
Configuration options for Series construction.
Properties
data
Get the underlying data array.Read-only view of the data array
index
Get the index labels.Read-only view of the index array
name
Get the Series name.The name of this Series, or undefined if not set
length
Get the number of elements in the Series.Length of the Series
Data Access
get()
Get a value by label. This method is an alias forloc(). It performs strict label-based lookup.
For positional access, use iloc().
The index label to look up
The value at that label, or undefined if not found
loc()
Access a value by label (label-based indexing).The index label to look up
The value at that label, or undefined if not found
iloc()
Access a value by integer position (position-based indexing).The integer position (0-based)
The value at that position, or undefined if out of bounds
Selection
head()
Return the first n elements.Number of elements to return
New Series with the first n elements
tail()
Return the last n elements.Number of elements to return
New Series with the last n elements
filter()
Filter Series by a boolean predicate function. Filters both data AND index to maintain alignment.Function that returns true for elements to keep
New Series with only elements that passed the predicate
Transformation
map()
Transform each element using a mapping function.Function to apply to each element
New Series with transformed values
sort()
Sort the Series values. Preserves index-value mapping by sorting[value, index] pairs.
Sort in ascending order
New sorted Series with index reordered to match
Unique Values
unique()
Get unique values in the Series.Array of unique values (order preserved)
valueCounts()
Count occurrences of unique values. Returns a Series where index is the unique values and data is their counts.Series where index is unique values and data is their counts
Statistical Methods
All statistical methods skip null, undefined, and NaN values.sum()
Calculate the sum of all values.Sum of all numeric values
mean()
Calculate the arithmetic mean (average) of all values.Mean of all numeric values
median()
Calculate the median (middle value) of all values. For even-length Series, returns the average of the two middle values.Median value
std()
Calculate the standard deviation of all values. Uses sample standard deviation (divides by n-1).Standard deviation
var()
Calculate the variance of all values. Uses sample variance (divides by n-1).Variance
min()
Find the minimum value in the Series.Minimum value
max()
Find the maximum value in the Series.Maximum value
Conversion
toArray()
Convert the Series to a plain JavaScript array. Returns a shallow copy of the data.Array copy of the data
toTensor()
Convert the Series to an ndarray Tensor.Tensor containing the Series data
toString()
Return a human-readable string representation of this Series. Each row is printed asindex value, with an optional name/length footer.
Large Series are truncated with an ellipsis.
Maximum rows to display before summarizing
Formatted string representation