Pandas Series – Attributes and Methods

The Series in Pandas is a one-dimensional array that uses the Series() method to create a Series, but it also uses different built-in attributes and methods for basic functionalities. In this lesson, let us see such attributes and methods in Python Pandas for Series:

  • dtype: Return the dtype.
  • ndim: Return the Number of dimensions
  • size: Return the number of elements.
  • name: Return the name of the Series.
  • hasnans: Returns True if NaNs are in the series.
  • index: The index of the series
  • head(): Return the first n rows.
  • tail(): Return the last n rows.
  • info(): Display the Summary of the series

Let us understand them one by one:

dtype

The pandas.series.dtype is used to return the datatype of the Series.

Let us now see an example to implement the type attribute in Python Pandas:

Output

ndim

The pandas.series.ndim is used to return the number of dimensions of the Series.

Let us now see an example to implement the ndim attribute in Python Pandas

Output

size

The pandas.series.size is used to return the number of elements in the Pandas Series.

Let us now see an example to implement the size attribute in Python Pandas:

Output

name

The pandas.series.name is used to return the name of the Series in Pandas.

Let us now see an example to implement the name attribute in Python Pandas:

Output

hasnans

The pandas.series.hasnans attribute returns True if NaNs are in the Pandas Series.

Let us now see an example to implement the hasnans attribute in Python Pandas:

Output

index

The pandas.series.index attribute is used to display the index of the Pandas Series.

Let us now see an example to implement the index attribute in Python Pandas:

Output

head()

The pandas.series.head() method is used to return the first n rows of the Pandas Series.

Let us now see an example to implement the head() method in Python Pandas:

Output

tail()

The pandas.series.tail() method is used to return the last n rows of the Pandas Series.

Let us now see an example to implement the tail() method in Python Pandas:

Output

info()

The pandas.series.info() method is used to display the Summary of the Pandas Series.

Let us now see an example to implement the info() method in Python Pandas:

Output

In this lesson, we saw what functionalities in the form of attributes and methods are present in Python Pandas Series.

If you liked the tutorial, spread the word and share the link and our website Studyopedia with others.


For Videos, Join Our YouTube Channel: Join Now


Read More:

Find and Remove Duplicates from rows in Pandas
DataFrame - Attributes and Methods
Studyopedia Editorial Staff
contact@studyopedia.com

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading