Creating a Pandas Series
Pandas Series is a one-dimensional labelled array capable of holding data of any type (integer, string, float, python objects, etc.). The axis labels are collectively called index.
Labels need not be unique but must be a hashable type. The object supports both integer and label-based indexing and provides a host of methods for performing operations involving the index.
Creating an empty Series :
A basic series, which can be created is an Empty Series.
Series(, dtype: float64)
Creating a series from array:
In order to create a series from array, we have to import a numpy module and have to use array() function.
Creating a series from array with index :
In order to create a series from array with index, we have to provide index with same number of element as it is in array.
Creating a series from Lists:
In order to create a series from list, we have to first create a list after that we can create a series from list.
Creating a series from Dictionary:
In order to create a series from dictionary, we have to first create a dictionary after that we can make a series using dictionary. Dictionary key are used to construct a index.
Creating a series from Scalar value:
In order to create a series from scalar value, an index must be provided. The scalar value will be repeated to match the length of index.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course