Thursday, July 2, 2026
HomeLanguagesHow to reshape Pandas Series?

How to reshape Pandas Series?

In this article, we will see how to reshaping Pandas Series. So, for reshaping the Pandas Series we are using reshape() method of Pandas Series object.

Syntax: Pandas.Series.values.reshape((dimension))

Return: return an ndarray with the values shape if the specified shape matches exactly the current shape, then return self (for compat)

Let’s see some of the examples:

Example 1:

Python3




# import pandas library
import pandas as pd
  
# make an array
array = [2, 4, 6, 8, 10, 12]
  
# create a series
series_obj = pd.Series(array)
  
# convert series object into array
arr = series_obj.values
  
# reshaping series 
reshaped_arr = arr.reshape((3, 2))
  
# show 
reshaped_arr


Output:

Example 2:

Python3




# import pandas library
import pandas as pd
  
# make an array
array = ["ankit","shaurya",
         "shivangi", "priya",
         "jeet","ananya"]
  
# create a series
series_obj = pd.Series(array)
  
print("Given Series:\n", series_obj)
  
# convert series object into array
arr = series_obj.values
  
# reshaping series 
reshaped_arr = arr.reshape((2, 3))
  
# show 
print("After Reshaping: \n", reshaped_arr)


Output:

RELATED ARTICLES

2 COMMENTS

Most Popular

Dominic
32518 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6900 POSTS0 COMMENTS
Nicole Veronica
12014 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12110 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6966 POSTS0 COMMENTS