Let us see how to connvert a Series of lists to a single Series in Pandas.
First of all let us create a Series of lists. For this problem we have created a Series of list having 12 elements, each list is of length 3 and there are 4 lists hence total elements are 12. When the Series of list will be converted to one it will have 12 elements.
Method 1: Using the extend() method
In this method, we iterate over each element of the Series and add it to a list, note that we are using the extend() method.
Method 2 : Using pd.concat() method
We iterate through each list in the series and convert it to Series object then we concatenate all the series along the rows to form the final Series. We also need to reset the index
Method 3: Using the apply() method.
The Series object has an apply() method which takes in a function as an argument and applies it to every element. We then stack all the elements and reset the index .
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Convert Series of lists to one Series in Pandas
- Add a Pandas series to another Pandas series
- Creating a Pandas Series from Lists
- Python | Zipping two lists of lists
- Python | Program to count number of lists in a list of lists
- Python - Convert Lists into Similar key value lists
- Python | Converting all strings in list to integers
- Converting an image to ASCII image in Python
- Python __iter__() and __next__() | Converting an object into an iterator
- Converting Color video to grayscale using OpenCV in Python
- Python | Converting list string to dictionary
- Python | Converting String content to dictionary
- Converting WhatsApp chat data into a Word Cloud using Python
- Converting Roman to Decimal in Python using gnboorse-rom module
- Converting Power Law Distribution to a Linear graph
- Converting a 10 digit phone number to US format using Regex in Python
- Python | Pandas series.cumprod() to find Cumulative product of a Series
- Python | Pandas Series.str.replace() to replace text in a series
- Python | Pandas Series.astype() to convert Data type of series
- Python | Pandas Series.cumsum() to find cumulative sum of a Series
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.