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 as pd
array = [ 2 , 4 , 6 , 8 , 10 , 12 ]
series_obj = pd.Series(array)
arr = series_obj.values
reshaped_arr = arr.reshape(( 3 , 2 ))
reshaped_arr
|
Output:

Example 2:
Python3
import pandas as pd
array = [ "ankit" , "shaurya" ,
"shivangi" , "priya" ,
"jeet" , "ananya" ]
series_obj = pd.Series(array)
print ( "Given Series:\n" , series_obj)
arr = series_obj.values
reshaped_arr = arr.reshape(( 2 , 3 ))
print ( "After Reshaping: \n" , reshaped_arr)
|
Output:

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
01 Oct, 2020
Like Article
Save Article