pandas Series is a one-dimensional sequential data structure that is able to handle any type of data, such as string, numeric, datetime, Python lists, and dictionaries with labels and indexes. Series is one of the columns of a DataFrame. We can create a Series using a Python dictionary, NumPy array, and scalar value. We will also see the pandas Series features and properties in the latter part of the section. Let's create some Python Series:
- Using a Python dictionary: Create a dictionary object and pass it to the Series object. Let's see the following example:
# Creating Pandas Series using Dictionary
dict1 = {0 : 'Ajay', 1 : 'Jay', 2 : 'Vijay'}
# Create Pandas Series
series = pd.Series(dict1)
# Show series
series
Output:
0 Ajay
1 Jay
2 Vijay
dtype: object
- Using a NumPy array: Create a NumPy array object and pass it to the Series object. Let's see the following example:
#Load Pandas and NumPy libraries
import...