Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Pandas · Class

Series

pandas.Series is a one-dimensional labeled data structure that supports positional and label-based indexing. Arithmetic aligns operands by their index labels.

How it works

Series stores one-dimensional data together with an index and optional name. It supports label-based and integer-based access, while arithmetic with another Series matches values by index and produces the sorted union of their indexes.

Syntax

class pandas.Series(*data=None*, *index=None*, *dtype=None*, *name=None*, *copy=None*)[source]

Parameters

NameTypeDescription
dataarray-like, Iterable, dict, or scalar valueArray-like, Iterable, dict, or scalar value containing the Series data.
indexarray-like or IndexArray-like or Index labels; labels must be hashable and match the data length.
dtypestr, numpy.dtype, or ExtensionDtype, optionalOutput data type; inferred from data when omitted.
nameHashable, default NoneName assigned to the Series.
copybool, default NoneWhether to copy the input data.

Returns

A pandas Series object containing the supplied data, index, dtype, and name.

Key points

  • Series represents one-dimensional labeled data and can also model time-series values.
  • Values can be selected using positional indexing or index labels.
  • Its API includes many methods that operate with or transform the Series index.
  • Arithmetic matches values by labels instead of assuming equal positional layouts.
  • The constructor's data input is the content from which the Series is created.
  • When dtype is omitted, pandas infers the output data type from the supplied data.

Common mistakes

  • Index labels may repeat, but every label must be hashable.
  • An explicitly supplied index must contain hashable values and match the data length.
  • Operations between Series can add labels that were absent from one input, because their indexes are unioned and sorted.

Example: Create and align Series values

import pandas as pd

s = pd.Series([10, 20, 30], index=["a", "b", "c"], name="scores")
print(s.loc["b"])
print((s + pd.Series([1, 2], index=["b", "c"])).dropna())

Creates a labeled Series, selects by label, and demonstrates index-aligned arithmetic.

When to use it

Labeled one-dimensional data

Represent a single labeled variable such as scores, measurements, or categories.

Time-series values

Work with timestamps and indexed observations in a time-series workflow.

Index-aware arithmetic

Combine or compare labeled values from different sources while preserving label correspondence.

Interview questions

QWhat is a pandas Series?

Series is a one-dimensional ndarray-like object with axis labels. It supports both integer-based and label-based indexing and includes methods for operations involving its index.

Follow-up: How does Series arithmetic handle different indexes? It aligns operands by their associated index values rather than by array position.

QWhat are the main Series constructor inputs?

The data argument supplies the stored values and may be array-like, iterable, a dictionary, or a scalar. The index argument supplies labels; without one, pandas uses a RangeIndex.

Follow-up: What constraint applies to an explicit index? Its values must be hashable and have the same length as the data.

QHow does pandas align two Series during arithmetic?

Series operations such as addition align values using their associated indexes, even when the operands have different lengths. The output index is the sorted union of both input indexes.

Follow-up: What should be checked after alignment? Labels missing from either operand can produce missing results, so inspect or handle those values explicitly.

  • pandas.DataFrame
  • pandas.Index
  • Series.loc
  • Series.iloc
  • Series.items
  • Series.resample

Source: pandas.Series — pandas documentation. Checked 2026-10-15.