I think you're almost there, try removing the extra square brackets around the lst's (Also you don't need to specify the column names when you're creating a dataframe from a dict like this):

import pandas as pd
lst1 = range(100)
lst2 = range(100)
lst3 = range(100)
percentile_list = pd.DataFrame(
    {'lst1Title': lst1,
     'lst2Title': lst2,
     'lst3Title': lst3
    })

percentile_list
    lst1Title  lst2Title  lst3Title
0          0         0         0
1          1         1         1
2          2         2         2
3          3         3         3
4          4         4         4
5          5         5         5
6          6         6         6
...

If you need a more performant solution you can use np.column_stack rather than zip as in your first attempt, this has around a 2x speedup on the example here, however comes at bit of a cost of readability in my opinion:

import numpy as np
percentile_list = pd.DataFrame(np.column_stack([lst1, lst2, lst3]), 
                               columns=['lst1Title', 'lst2Title', 'lst3Title'])
Answer from miriamsimone on Stack Overflow
Top answer
1 of 2
52

Starting from Pandas 0.25.0, there is internal method DataFrame.explode(), which was designed just for that:

res = df.explode("b")

output

In [98]: res
Out[98]:
   a  b
0  1  1
0  1  2
1  2  2
1  2  3
1  2  4
2  3  5

Solution for Pandas versions < 0.25: generic vectorized approach - will work also for multiple columns DFs:

assuming we have the following DF:

In [159]: df
Out[159]:
   a          b  c
0  1     [1, 2]  5
1  2  [2, 3, 4]  6
2  3        [5]  7

Solution:

In [160]: lst_col = 'b'

In [161]: pd.DataFrame({
     ...:     col:np.repeat(df[col].values, df[lst_col].str.len())
     ...:     for col in df.columns.difference([lst_col])
     ...: }).assign(**{lst_col:np.concatenate(df[lst_col].values)})[df.columns.tolist()]
     ...:
Out[161]:
   a  b  c
0  1  1  5
1  1  2  5
2  2  2  6
3  2  3  6
4  2  4  6
5  3  5  7

Setup:

df = pd.DataFrame({
    "a" : [1,2,3],
    "b" : [[1,2],[2,3,4],[5]],
    "c" : [5,6,7]
})

Vectorized NumPy approach:

In [124]: pd.DataFrame({'a':np.repeat(df.a.values, df.b.str.len()),
                        'b':np.concatenate(df.b.values)})
Out[124]:
   a  b
0  1  1
1  1  2
2  2  2
3  2  3
4  2  4
5  3  5

OLD answer:

Try this:

In [89]: df.set_index('a', append=True).b.apply(pd.Series).stack().reset_index(level=[0, 2], drop=True).reset_index()
Out[89]:
   a    0
0  1  1.0
1  1  2.0
2  2  2.0
3  2  3.0
4  2  4.0
5  3  5.0

Or bit nicer solution provided by @Boud:

In [110]: df.set_index('a').b.apply(pd.Series).stack().reset_index(level=-1, drop=True).astype(int).reset_index()
Out[110]:
   a  0
0  1  1
1  1  2
2  2  2
3  2  3
4  2  4
5  3  5
2 of 2
1

Here is another approach with itertuples -

df = pd.DataFrame({"a" : [1,2,3], "b" : [[1,2],[2,3,4],[5]]})

data = []

for i in df.itertuples():
    lst = i[2]
    for col2 in lst:
        data.append([i[1], col2])

df_output = pd.DataFrame(data =data, columns=df.columns)
df_output 

Output is -

        a   b
    0   1   1
    1   1   2
    2   2   2
    3   2   3
    4   2   4
    5   3   5

Edit: You can also compress the loops into a single code and populate data as -

data = [[i[1], col2] for i in df.itertuples() for col2 in i[2]]
Discussions

python - How to save multiple lists into multiple rows in Pandas? - Stack Overflow
So I have multiple lists that I would like to convert them to some soft of table format. list1 has 1 2 3 list2 has 4 5 6 etc. I would like to save this into a table format such as list_1, list 2 ... More on stackoverflow.com
🌐 stackoverflow.com
Pandas: Create several rows from column that is a list - Stack Overflow
Communities for your favorite technologies. Explore all Collectives · Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work More on stackoverflow.com
🌐 stackoverflow.com
python - converting list like column values into multiple rows using Pandas DataFrame - Stack Overflow
CSV file: (sample1.csv) Location_City, Location_State, Name, hobbies Los Angeles, CA, John, "['Music', 'Running']" Texas, TX, Jack, "['Swimming', 'Trekking']" I w... More on stackoverflow.com
🌐 stackoverflow.com
April 22, 2021
python - How to use multiple lists of lists to append new rows to a dataframe? - Stack Overflow
@AkshaySehgal - yes, I only want say - if working with lists faster is use lsit comprehension like any pandas method. Unfortunately explode is slow in pandas. ... @AkshaySehgal - but if working with DataFrame or Series filled by lists then is only method in pandas for it. More on stackoverflow.com
🌐 stackoverflow.com
🌐
IncludeHelp
includehelp.com › python › how-to-convert-multiple-lists-into-dataframe.aspx
How to convert multiple lists into DataFrame?
# Importing pandas package import pandas as pd # Creating an array arr1 = ['Aman', 21, 18000] arr2 = ['Gaurav', 21, 11000] arr3 = ['Dhruv', 28, 8000] arr4 = ['Yuvraj', 19, 5000] arr5 = ['Divyansh', 24, 10700] arr6 = ['Kohli', 23, 12300] final_arr = [arr1,arr2,arr3,arr4,arr5,arr6] # Creating a DataFrame df = pd.DataFrame(final_arr, columns=['Name','Age','Salary']) # Display created DataFrame print("Created DataFrame:\n",df,"\n") ... How to create separate rows for each list item where the list is itself an item of a pandas DataFrame column?
🌐
Board Infinity
boardinfinity.com › blog › list-to-dataframes
Converting List to DataFrames in Pandas | Board Infinity
July 16, 2023 - Multiple lists are combined into one DataFrame, with column names and indexes specified. But let's first make some lists. Let's begin by building a DataFrame from a single list. To do this, I'll call pd.DataFrame and provide data=my list. As you can see, pandas provides a single column DataFrame when I feed it one list. The row inside a single column represents the list values.
🌐
PYnative
pynative.com › home › python › pandas › create pandas dataframe from python list
Create Pandas DataFrame from Python List
March 9, 2023 - It may be possible to have data scattered into multiple lists or in the list of lists, also called a multi-dimensional list. In such a case, We can pass such a list to the DataFrame constructor to convert it into the DataFrame. By default, it adds each list as a row in the resultant DataFrame.
🌐
Edureka Community
edureka.co › home › community › categories › python › pandas dataframe with multiple lists in python
Pandas dataframe with multiple lists in Python | Edureka Community
April 6, 2019 - Hi. I want to create a Pandas dataframe in Python. But the problem is that I have two lists. I know I ... [ Name']) But how to do it with 2 lists?
🌐
GitHub
gist.github.com › jlln › 338b4b0b55bd6984f883
Efficiently split Pandas Dataframe cells containing lists into multiple rows, duplicating the other column's values. · GitHub
For example instead of one column which is a comma delimited list I have multiple columns which correspond to each other. col a | col b | col c | a, b, c 1, 2, 3, 2.0, 3.0, 4.0 · Turns into col a | col b | col c | a, 1, 2.0 b, 2, 3.0 c, 3, 4.0 ... This variation might be a bit faster. def split_data_frame_list(df, target_column): """ Splits a column with lists into rows Keyword arguments: df -- dataframe target_column -- name of column that contains lists """ # create a new dataframe with each item in a seperate column, dropping rows with missing values col_df = pd.DataFrame(df[target_column].dropna().tolist(),index=df[target_column].dropna().index) # create a series with columns stacked as rows stacked = col_df.stack() # rename last column to 'idx' index = stacked.index.rename(names="idx", level=-1) new_df = pd.DataFrame(stacked, index=index, columns=[target_column]) return new_df
Find elsewhere
🌐
Easy Tweaks
easytweaks.com › multiple-lists-to-dataframe-python
How to create a Pandas DataFrame from multiple lists?
Master meetings, chats, channels and online collaboration · Go beyond the basics in Word, Excel, PowerPoint and Outlook
Top answer
1 of 2
2

We can solve this using pandas.DataFrame.explode function which was introduced in version 0.25.0 if you have same or higher version, you can use below code.
explode function reference: https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.explode.html

import pandas as pd
import ast

data = {
    'Location_City': ['Los Angeles','Texas'],
    'Location_State': ['CA','TX'],
    'Name': ['John','Jack'],
    'hobbies': ["['Music', 'Running']", "['Swimming', 'Trekking']"]
}
df = pd.DataFrame(data)

# Converting a string representation of a list into an actual list object

list_eval = lambda x: ast.literal_eval(x)
df['hobbies'] = df['hobbies'].apply(list_eval)

# Exploding the list
df = df.explode('hobbies')

print(df)

  Location_City Location_State  Name   hobbies
0   Los Angeles             CA  John     Music
0   Los Angeles             CA  John   Running
1         Texas             TX  Jack  Swimming
1         Texas             TX  Jack  Trekking
2 of 2
1

You can use findall or extractall for get lists from hobbies colum, then flatten with chain.from_iterable and repeat another columns:

a = df['hobbies'].str.findall("'(.*?)'").astype(np.object)
lens = a.str.len()

from itertools import chain

df1 = pd.DataFrame({
    'Location_City' : df['Location_City'].values.repeat(lens),
    'Location_State' : df['Location_State'].values.repeat(lens),
    'Name' : df['Name'].values.repeat(lens),
    'hobbies' : list(chain.from_iterable(a.tolist())), 
})

Or create Series, remove first level and join to original DataFrame:

df1 = (df.join(df.pop('hobbies').str.extractall("'(.*?)'")[0]
               .reset_index(level=1, drop=True)
               .rename('hobbies'))
         .reset_index(drop=True))

print (df1)

  Location_City Location_State  Name   hobbies
0   Los Angeles             CA  John     Music
1   Los Angeles             CA  John   Running
2         Texas             TX  Jack  Swimming
3         Texas             TX  Jack  Trekking
🌐
Analytics Vidhya
analyticsvidhya.com › home › how to create a pandas dataframe from lists ?
Create a Pandas DataFrame from Lists - Analytics Vidhya
April 22, 2025 - Let’s explore some of them: ... A multi-index DataFrame is a DataFrame with multiple levels of row and column indices. It can be created using the `pd.MultiIndex.from_arrays()` function.
Top answer
1 of 3
1

Here you go, just add column 'C' and you are sorted. Just to note, you must be seeking a pandas solution because merge is a pandas command and you're asking for a Python solution.

import pandas as pd

a = ["house","garden", "living room", "dog","cat"]
b= ["cat","dog", "chicken"]
df = pd.DataFrame(a, columns = ['a'])
df2 = pd.DataFrame(b, columns = ['b'])
dfa = df['a'].value_counts()
dfa.columns = ['a']
dfb = df2['b'].value_counts()
dfb.columns = ['b']
dfa = dfa.to_frame()
dfb = dfb.to_frame()
df3 = dfa.join(dfb).replace(np.nan, 0).astype(int)
print (df3)

Output

             a  b
house        1  0
garden       1  0
living room  1  0
dog          1  1
cat          1  1

and if you want to remove the 'a' column

print (df3.drop('a', axis=1))

             b
house        0
garden       0
living room  0
dog          1
cat          1

Notes The key command here is value_counts and makes a frequency plot. Its output is a Series rather than a DataFrame so it needs converting.

If you want to keep all inputs the commands is

df3 = pd.concat([dfa, dfb]).replace(np.nan, 0).astype(int)

Alternatively,

a = ["house","garden", "living room", "dog","cat"]
b= ["cat","dog", "chicken"]
df = pd.DataFrame(a).value_counts().to_frame('a')
df2 = pd.DataFrame(b).value_counts().to_frame('b')
df3 = df.join(df2).replace(np.nan, 0).astype(int).rename_axis(None)
print (df3.drop('a', axis=1))
2 of 3
1

I'm aware that this asks specifically for a python solution, but I'd like to add an R answer as well, just in case someone using R has a similar problem:

> a <- c("house","garden", "living room", "dog","cat")
> b <- c("cat","dog", "chicken")
> c <- c("house", "garden","bathroom")

> (result <- data.frame(row.names=a, a=a %in% a, b=a %in% b, c=a %in% c))
               a     b     c
house       TRUE FALSE  TRUE
garden      TRUE FALSE  TRUE
living room TRUE FALSE FALSE
dog         TRUE  TRUE FALSE
cat         TRUE  TRUE FALSE

or for strictly what you asked for, the TRUE/FALSE values can be encouraged into numbers by adding zero:

> (result <- data.frame(a=a, b=(a %in% b) + 0, c=(a %in% c) + 0))
            a b c
1       house 0 1
2      garden 0 1
3 living room 0 0
4         dog 1 0
5         cat 1 0
🌐
datagy
datagy.io › home › pandas tutorials › pandas reading & writing data › pandas: create a dataframe from lists (5 ways!)
Pandas: Create a Dataframe from Lists (5 Ways!) • datagy
December 15, 2022 - Check out some other Python tutorials on datagy, including our complete guide to styling Pandas and our comprehensive overview of Pivot Tables in Pandas! In this post, you learned different ways of creating a Pandas dataframe from lists, including working with a single list, multiple lists with the zip() function, multi-dimensional lists of lists, and how to apply column names and datatypes to your dataframe.
🌐
Medium
ianh6ll6n.medium.com › expanding-a-pandas-list-column-to-rows-41c69aaf9488
Expanding a pandas list column to rows | by Ian Hellen | Medium
March 19, 2021 - If the input data has rows with different numbers of list elements, we end up with Python None objects all over the place. We need to get rid of these but pandas doesn’t have any clever way of dropping them efficiently (as it can with NaN values). The pandas replace function can sort this out for us. I’ve added back Bartosz’ merge and melt lines since already these work perfectly. orig_cols = df2.columns ( pd.DataFrame(df2.IPAddresses.to_list()) .replace([None], np.nan) .merge(df2, right_index=True, left_index=True) .melt(id_vars=orig_cols, value_name="IPAddress") )
🌐
IncludeHelp
includehelp.com › python › how-to-select-multiple-rows-from-a-pandas-dataframe.aspx
How to select multiple rows from a Pandas DataFrame?
The pandas.DataFrame.loc property allows us to select a row by its column value. To select multiple rows, we can also use the loc[] property by defining the number of rows along with column names (in case we don't need all the columns).
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › create-a-list-from-rows-in-pandas-dataframe
Create a list from rows in Pandas dataframe - GeeksforGeeks
July 28, 2025 - Explanation: Similar to values.tolist(), this method explicitly converts the DataFrame into a NumPy array using to_numpy(). This method converts each row into a dictionary, where column names serve as keys. This is particularly useful when working with structured data that needs to retain column labels. ... import pandas as pd # Create the dataframe df = pd.DataFrame({'Date': ['10/2/2011', '11/2/2011', '12/2/2011', '13/2/2011'], 'Event': ['Music', 'Poetry', 'Theatre', 'Comedy'], 'Cost': [10000, 5000, 15000, 2000]}) res = df.to_dict(orient='records') print(res)