Pandas Series

A Pandas Series is a one-dimensional labeled array capable of holding any data type (integers, strings, floats, etc.). It is similar to a column in an Excel sheet or a database table. Each value in a Series is associated with an index, making it easy to retrieve data by labels or position.

Creating a Pandas Series

You can create a Pandas Series from a list, dictionary, or even a scalar value. Let us start with a simple example using Tamil fruits:

import pandas as pd

# Create a Pandas Series using a list
fruits = ["Mango", "Banana", "Jackfruit", "Guava"]
series = pd.Series(fruits)

# Display the Series
print(series)

Output

Index Value
0 Mango
1 Banana
2 Jackfruit
3 Guava

dtype: object

Explanation:

  • The list fruits contains names of fruits in Tamil Nadu.
  • pd.Series() converts the list into a Pandas Series, where each item is assigned an index automatically (starting from 0).
  • The output shows the indices, values, and data type of the Series.

Key Takeaways

  • A Pandas Series is a one-dimensional labeled array, similar to a column in a table.
  • It can be created from lists, dictionaries, or scalar values.
  • Indices allow easy access to specific elements in the Series.
  • Series are a fundamental building block for working with data in Pandas.