Can I ask why not just do it by slicing the data frame. Something like

#create some data with Names column
data = pd.DataFrame({'Names': ['Joe', 'John', 'Jasper', 'Jez'] *4, 'Ob1' : np.random.rand(16), 'Ob2' : np.random.rand(16)})

#create unique list of names
UniqueNames = data.Names.unique()

#create a data frame dictionary to store your data frames
DataFrameDict = {elem : pd.DataFrame() for elem in UniqueNames}

for key in DataFrameDict.keys():
    DataFrameDict[key] = data[:][data.Names == key]

Hey presto you have a dictionary of data frames just as (I think) you want them. Need to access one? Just enter

DataFrameDict['Joe']
Answer from Woody Pride on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › split-pandas-dataframe-by-rows
Split Pandas Dataframe by Rows - GeeksforGeeks
July 15, 2025 - In this article, we will elucidate several commonly employed methods for Split Pandas Dataframe by Rows. These methods are widely utilized for the purpose of dividing a Pandas DataFrame, and we will discuss the which are following: Using Row Index · In Groups From Unique Column Values · Using Predetermined-Sized Chunks · By Shuffling Rows · Consider a dataset: To illustrate, let's consider a dataset featuring information about diamonds. Python3 ·
Top answer
1 of 13
113

Can I ask why not just do it by slicing the data frame. Something like

#create some data with Names column
data = pd.DataFrame({'Names': ['Joe', 'John', 'Jasper', 'Jez'] *4, 'Ob1' : np.random.rand(16), 'Ob2' : np.random.rand(16)})

#create unique list of names
UniqueNames = data.Names.unique()

#create a data frame dictionary to store your data frames
DataFrameDict = {elem : pd.DataFrame() for elem in UniqueNames}

for key in DataFrameDict.keys():
    DataFrameDict[key] = data[:][data.Names == key]

Hey presto you have a dictionary of data frames just as (I think) you want them. Need to access one? Just enter

DataFrameDict['Joe']
2 of 13
79

Firstly your approach is inefficient because the appending to the list on a row by basis will be slow as it has to periodically grow the list when there is insufficient space for the new entry, list comprehensions are better in this respect as the size is determined up front and allocated once.

However, I think fundamentally your approach is a little wasteful as you have a dataframe already so why create a new one for each of these users?

I would sort the dataframe by column 'name', set the index to be this and if required not drop the column.

Then generate a list of all the unique entries and then you can perform a lookup using these entries and crucially if you only querying the data, use the selection criteria to return a view on the dataframe without incurring a costly data copy.

Use pandas.DataFrame.sort_values and pandas.DataFrame.set_index:

# sort the dataframe
df.sort_values(by='name', axis=1, inplace=True)

# set the index to be this and don't drop
df.set_index(keys=['name'], drop=False,inplace=True)

# get a list of names
names=df['name'].unique().tolist()

# now we can perform a lookup on a 'view' of the dataframe
joe = df.loc[df.name=='joe']

# now you can query all 'joes'
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.Series.str.split.html
pandas.Series.str.split — pandas 3.0.4 documentation - PyData |
Without the n parameter, the outputs of rsplit and split are identical. >>> s.str.rsplit() 0 [this, is, a, regular, sentence] 1 [https://docs.python.org/3/tutorial/index.html] 2 NaN dtype: object
🌐
datagy
datagy.io › home › pandas tutorials › pandas dataframes › python: split a pandas dataframe
Python: Split a Pandas Dataframe • datagy
December 16, 2022 - Learn how to split a Pandas dataframe in Python. Split a dataframe by column value, by position, and by random values.
🌐
Spark By {Examples}
sparkbyexamples.com › home › pandas › how to split pandas dataframe?
How to Split Pandas DataFrame? - Spark By {Examples}
December 6, 2024 - You can split the Pandas DataFrame based on rows or columns by using Pandas.DataFrame.iloc[] attribute, groupby().get_group(), sample() functions. It
🌐
Delft Stack
delftstack.com › home › howto › python pandas › split pandas dataframe
How to Split Pandas DataFrame | Delft Stack
February 2, 2024 - Python ScipyPythonPython TkinterBatchPowerShellPython PandasNumpyPython FlaskDjangoMatplotlibDockerPlotlySeabornMatlabLinuxGitCCppHTMLJavaScriptjQueryPython PygameTensorFlowTypeScriptAngularReactCSSPHPJavaGoKotlinNode.jsCsharpRustRubyArduinoMySQLMongoDBPostgresSQLiteRVBAScalaRaspberry Pi ... This tutorial explains how we can split a DataFrame into multiple smaller DataFrames using row indexing, the DataFrame.groupby() method, and DataFrame.sample() method.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › python › split-pandas-dataframe-by-column-index
Split Pandas Dataframe by Column Index - GeeksforGeeks
July 15, 2025 - Python3 · Y = df.iloc[:,4] Y · Output: Example 3: Splitting dataframes into 2 separate dataframes ·
🌐
Medium
medium.com › @tubelwj › how-to-split-columns-in-a-dataframe-using-python-pandas-05272d17f4f2
How to Split Columns in a DataFrame Using Python Pandas | by Gen. Devin DL. | Medium
December 21, 2024 - In addition to splitting column data directly based on characters, we can also use regular expressions to split. For example, in the following scenario, we need to mask a customer’s phone number. This can be achieved by truncating the number using a regular expression, keeping only the last four digits. import pandas as pd # Create a DataFrame with six phone numbers df = pd.DataFrame( { "OrderNumber": ["01", "02", "03", "04", "05", "06"], "PhoneNumber": [ "5551234567", "5559876543", "5556543210", "5558765432", "5552345678", "5557654321", ], } ) # Truncate the phone numbers to keep only the last 4 digits df["TruncatedPhoneNumber"] = df["PhoneNumber"].str.split( r"\d{6}", # Matches the first 6 digits expand=True, regex=True, )[1] print(df)
🌐
Medium
medium.com › @amit25173 › how-to-split-dataframe-into-chunks-in-pandas-6c1282e31552
How to Split DataFrame into Chunks in Pandas? | by Amit Yadav | Medium
March 6, 2025 - NumPy’s array_split() handles everything for you, even when the data isn't evenly divisible. 🔹 How does it work? It automatically distributes rows across chunks, even if the total number of rows isn’t a multiple of the chunk size. import pandas as pd import numpy as np # Sample DataFrame df = pd.DataFrame({'A': range(1, 11), 'B': range(11, 21)}) # Splitting into 3 chunks chunks = np.array_split(df, 3) # Displaying chunks for i, chunk in enumerate(chunks): print(f"Chunk {i+1}:\n", chunk, "\n")
🌐
Saturn Cloud
saturncloud.io › blog › how-to-split-pandas-dataframe-column-values-in-python
How to Split Pandas Dataframe Column Values in Python | Saturn Cloud Blog
May 1, 2026 - In this article, we explored how to split Pandas dataframe column values in Python. We learned how to split a column into two columns using a single separator and how to split a column into multiple columns using multiple separators.
🌐
Reddit
reddit.com › r/learnpython › splitting pandas dataframe based on row difference
r/learnpython on Reddit: Splitting Pandas Dataframe based on row difference
December 23, 2024 - import pandas as pd df = pd.DataFrame ({ 'count': [3, 4, 5, 6, 7, 15, 16, 17, 18, 19, 20], 'Time': [400, 500, 600, 700, 800, 1600, 1700, 1800, 1900, 2000, 2100] }) df['g'] = ((df['count'].diff().gt(1)) | (df['Time'].diff().gt(100))).cumsum() grouped = df.groupby('g') #group the rows based on temp column 'g' df_list = [] for g, dfg in grouped: df_list.append(dfg.drop('g', axis = 1).reset_index(drop = True)) ... Working with Pandas and making new columns from str.split.
🌐
Untitled Publication
elisa.hashnode.dev › split-a-dataframe
Split a Pandas Dataframe in Python - Elisa's Blog - Hashnode
September 29, 2021 - Split a Pandas Dataframe into two parts, either sequentially or randomly. Select the number of rows or size ratio for the split dataframes.
🌐
Medium
medium.com › @heyamit10 › master-pandas-split-column-by-delimiter-f66d0a602e4d
Master pandas Split Column by Delimiter | by Hey Amit | Medium
April 12, 2025 - When you’re ready to split a column in your DataFrame, the str.split() method is what you need.
🌐
GeeksforGeeks
geeksforgeeks.org › python › split-dataframe-in-pandas-based-on-values-in-multiple-columns
Split dataframe in Pandas based on values in multiple columns - GeeksforGeeks
July 23, 2025 - In this article, we are going to see how to divide a dataframe by various methods and based on various parameters using Python.
🌐
IncludeHelp
includehelp.com › python › splitting-dataframe-into-multiple-dataframes-based-on-column-values-and-naming-them-with-those-values.aspx
Python - Splitting dataframe into multiple dataframes based on column values and naming them with those values
November 16, 2022 - # Importing pandas package import pandas as pd # Importing numpy package import numpy as np # Creating a dictionary d= { 'brand':['Nike','Nike','Nike','Puma','Puma','Puma','Reebok','Reebok','Reebok'], 'Region':['A','B','C','A','B','C','A','B','C'], 'product':['Tshirt','Shoes','Jacket','Tshirt','Shoes','Jacket','Tshirt','Shoes','Jacket'] } # Creating DataFrame df = pd.DataFrame(d) # Display dataframe print('Original DataFrame:\n',df,'\n') i = 1 # Using groupby and splitting df for region, df_region in df.groupby('Region'): print("Subset "+str(i)+"\n",df_region,"\n") i=i+1 · The output of the above program is: Python Pandas Programs » ·
🌐
GeeksforGeeks
geeksforgeeks.org › split-pandas-dataframe-by-column-value
Split Pandas Dataframe by column value - GeeksforGeeks
April 20, 2022 - In this article, we are going to see how to divide a dataframe by various methods and based on various parameters using Python. To divide a dataframe into two or more separate dataframes based on the values present in the column we first create a data frame. Creating a DataFrame for demonestrationPy ... In this article, we will explore the process of Split Pandas Dataframe by Rows.
🌐
w3resource
w3resource.com › python-exercises › pandas › python-pandas-data-frame-exercise-67.php
Pandas: Split a given DataFrame into two random subsets - w3resource
Write a Pandas program to split a given DataFrame into two random subsets. Sample Solution : Python Code : import pandas as pd df = pd.DataFrame({ 'name': ['Alberto Franco','Gino Mcneill','Ryan Parkes', 'Eesha Hinton', 'Syed Wharton'], 'date_of_birth': ['17/05/2002','16/02/1999','25/09/1998','11/05/2002','15/09/1997'], 'age': ['18', '21', '22', '22', '23'] }) df_1 = df.sample(frac = 0.6) df_2 = df.drop(df_1.index) print("Original Dataframe and shape:") print(df) print(df.shape) print("\nSubset-1 and shape:") print(df_1) print(df_1.shape) print("\nSubset-2 and shape:") print(df_2) print(df_2.sh