Create a Pandas Series from Array (original) (raw)

Last Updated : 17 Mar, 2025

A **Pandas Series is a one-dimensional labeled array that stores various data types, including numbers (integers or floats), strings, and Python objects. It is a fundamental data structure in the Pandas library used for efficient data manipulation and analysis. In this guide we will explore two simple methods to create a Pandas **Series from a NumPy array.

Creating a Pandas Series Without an Index

By default when you create a Series from a NumPy array Pandas automatically assigns a numeric index starting from **0. Here pd.Series(data) converts the array into a **Pandas Series automatically assigning an index.

Python `

import pandas as pd import numpy as np

data = np.array(['a', 'b', 'c', 'd', 'e'])

s = pd.Series(data) print(s)

`

**Output:

Screenshot-2025-03-15-194119

**Explanation:

Creating a Pandas Series With a Custom Index

In this method we specify custom indexes instead of using Pandas’ default numerical indexing. This is useful when working with structured data, such as **employee IDs, timestamps, or product codes where meaningful indexes enhance data retrieval and analysis.

Python `

import pandas as pd import numpy as np

data = np.array(['a', 'b', 'c', 'd', 'e'])

s = pd.Series(data, index=[1000, 1001, 1002, 1003, 1004])

print(s)

`

**Output:

Screenshot-2025-03-15-194326

**Explanation:

Creating a Pandas Series from a NumPy array is simple and efficient. You can use the default index for quick access or assign a custom index for better data organization.

Similar Reads

Pandas DataFrame Practice Exercises



















Pandas Dataframe Rows Practice Exercise

















Pandas Dataframe Columns Practice Exercise



























Pandas Series Practice Exercise






Pandas Date and Time Practice Exercise




DataFrame String Manipulation




Accessing and Manipulating Data in DataFrame






DataFrame Visualization and Exporting