๐ Pandas Series Attributes & Methods โ Explained with Notes


When working with one-dimensional labeled arrays in Pandas (i.e., Series
), it's important to understand the built-in attributes and methods that allow you to inspect, transform, and manipulate data effectively.
This post summarizes all key Series attributes and methods with explanations and practical insights. ๐ง โจ
๐งฉ Series Attributes
Series attributes help you inspect metadata and structure of your Series object.
Attribute | Description |
size | Returns the total number of values in the Series. |
dtype | Data type of the Series (e.g., int64 , float , object ). |
name | Name assigned to the Series. |
index.name | Name of the index (label for the index column). |
index | Range or custom index assigned to the Series. |
values | Returns the underlying NumPy array of values. |
is_unique | Returns True if all values are unique; otherwise False . |
hasnans | Checks for presence of missing values (NaN ). |
๐ ๏ธ Series Methods
These methods help analyze, clean, modify, and visualize Series data.
๐ข Value Counts & Sorting
value_counts(ascending=False)
: Frequency count of unique values.count()
: Total non-null entries.sort_values(ascending=True)
: Sort Series by values.sort_index(ascending=False)
: Sort Series by index.
๐งน Duplicate Handling
duplicated(keep='first')
: Mark duplicates asTrue
.drop_duplicates(keep='first')
: Remove duplicates.
๐งผ Null Handling
isnull()
/notnull()
: Boolean Series indicating null status.dropna()
: Remove null entries.fillna(value)
: Fill null values with a specific value.ffill()
/bfill()
: Forward-fill / backward-fill missing values.
๐ Visualization
plot(kind='bar'/'pie'/etc)
: Plot data using matplotlib backend.
๐งฎ Statistical Methods
sum()
/mean()
/min()
/max()
/std()
/var()
/mode()
/describe()
/product()
: Standard stats methods.
๐ Filtering & Range
between(lower, upper)
: Check if values fall between range.clip(lower, upper)
: Restrict values to given bounds.
๐ง Functional Operations
apply(func)
: Apply a custom function to each element.map(func)
: Similar to apply; useful for mapping values.astype(type)
: Convert Series to another data type.pd.to_numeric(errors='ignore'/'coerce')
: Convert to numeric, handling errors.
๐ข Indexing & Selection
loc[]
: Label-based access.iloc[]
: Position-based access.head(n)
/tail(n)
: Top or bottomn
entries.sample(n)
: Random sample of entries.
๐ Extra Notes:
NaN
is treated as float by default.You can convert a column from a
.csv
file directly into a Series using:pd.read_csv('file.csv', index_col='column').squeeze()
๐ Index & Membership
reset_index()
: Convert Series to DataFrame.unique()
/nunique(dropna=True)
: Get unique values or count.rank(ascending=False, method='mean')
: Rank elements in Series.idxmax()
/idxmin()
: Get index of max/min value.drop(index=[])
: Drop specific indices.isin([])
: Check if multiple values exist in the Series.
๐ Membership & Looping
Letโs say we have:
movies = pd.Series([...])
Membership:
'Avengers' in movies
: Checks if index exists.'Avengers' in movies.values
: Checks if value exists.
Looping:
for i in movies: # Loop through values
print(i)
for i in movies.index: # Loop through indices
print(i)
๐ Bonus Resource
๐ Check out my complete GitHub repo with well-organized Jupyter notebooks for NumPy, Pandas, and real-world data analysis projects:
๐ GitHub: Python Data Analysis
โ๏ธ Summary from My Personal Notes (Handwritten Reference)
I often learn best through handwritten notes. Hereโs a quick snapshot of extra tips and lesser-known functionalities I noted down while learning Pandas Series
.
๐ฌ Final Thoughts
Pandas Series offers powerful, flexible methods that make it easy to manipulate one-dimensional data. Mastering these attributes and methods is a foundational step in becoming a proficient data analyst or scientist.
If you found this helpful, follow my journey as I cover the complete data analysis pipeline step-by-step on my blog.
๐ Blog: Shehzified Blogs
Subscribe to my newsletter
Read articles from Shehzified directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Shehzified
Shehzified
I'm Shehraz Sarwar, a CS student at IUGC and Silver Medalist from FAST. I love blending code with creativity, exploring Python, Data Science, AI, and the real-world magic of math. With a strong base in Python and Data Analysis, along with C, C++, and Java, I tackle problems through hands-on projects. Beyond code, I dive into video editing, 3D art, and UI/UX design, fueling my journey to become a versatile Computer Scientist.