๐Ÿ“Š Pandas Series Attributes & Methods โ€“ Explained with Notes

ShehzifiedShehzified
3 min read

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.

AttributeDescription
sizeReturns the total number of values in the Series.
dtypeData type of the Series (e.g., int64, float, object).
nameName assigned to the Series.
index.nameName of the index (label for the index column).
indexRange or custom index assigned to the Series.
valuesReturns the underlying NumPy array of values.
is_uniqueReturns True if all values are unique; otherwise False.
hasnansChecks 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 as True.

  • 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 bottom n 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

10
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.