๐ŸŒ
Pandas
pandas.pydata.org โ€บ docs โ€บ reference โ€บ api โ€บ pandas.concat.html
pandas.concat โ€” pandas 3.0.2 documentation - PyData |
When concatenating along the columns (axis=1), a DataFrame is returned. ... Join DataFrames using indexes. ... Merge DataFrames by indexes or columns. ... The keys, levels, and names arguments are all optional. A walkthrough of how this method fits in with other tools for combining pandas objects can be found here.
๐ŸŒ
Pandas
pandas.pydata.org โ€บ docs โ€บ user_guide โ€บ merging.html
Merge, join, concatenate and compare โ€” pandas 3.0.2 documentation
If you have a Series that you want to append as a single row to a DataFrame, you can convert the row into a DataFrame and use concat(). In [41]: s2 = pd.Series(["X0", "X1", "X2", "X3"], index=["A", "B", "C", "D"]) In [42]: result = pd.concat([df1, s2.to_frame().T], ignore_index=True) In [43]: ...
Discussions

python - How do I combine two dataframes? - Stack Overflow
I want to combine A and B into one DataFrame. The order of the data is not important. However, when we sample A and B from D, they retain their indexes from D. ... From pandas v1.4.1: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
python - Concatenate rows of two dataframes in pandas - Stack Overflow
The resultant dataframe will have the same number of rows nRow and number of columns equal to the sum of number of columns in both the dataframes. In other words, this is a blind columnar concatenation of two dataframes. import pandas as pd dict_data = {'Treatment': ['C', 'C', 'C'], 'Biorep': ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Quickest way to concat two columns in Pandas based on condition?
What is not working with your first line that combines the state and zip? That works fine for me. The only thing that's missing is the space, but that isn't required for UK postcodes. If you are trying to get everything back into a combined Zip column, you can use this: df["Final Zip"] = df["New Zipcode"].combine_first(df["Zip"]) df = df.drop(columns=["Zip", "New Zipcode"]).rename(columns={"Final Zip": "Zip"}) That will create a new column called "Final Zip" and pull in everything from "New Zipcode", and fill NA values with those from "Zip". Then drop the old zip columns and rename "Final Zip" to "Zip". More on reddit.com
๐ŸŒ r/learnpython
4
3
June 19, 2024
how to concat/join/merge two dataframes neglecting both indexes and column names?
pd.concat() how="outer" If you have a couple rows of data from both as an example I can show you how. https://www.geeksforgeeks.org/pandas-concat-function-in-python/ More on reddit.com
๐ŸŒ r/learnpython
2
3
February 23, 2024
๐ŸŒ
Spark By {Examples}
sparkbyexamples.com โ€บ home โ€บ pandas โ€บ pandas concat two dataframes explained
Pandas Concat Two DataFrames Explained - Spark By {Examples}
June 13, 2025 - You can use the pandas.concat() function to concatenate or merge two or more pandas DataFrames either along rows or columns. When concatenating DataFrames along rows, concat() creates a new DataFrame that includes all rows from the input DataFrames, ...
๐ŸŒ
Pandas
pandas.pydata.org โ€บ pandas-docs โ€บ stable โ€บ reference โ€บ api โ€บ pandas.concat.html
pandas.concat โ€” pandas 2.3.3 documentation - PyData |
When concatenating along the columns (axis=1), a DataFrame is returned. ... Join DataFrames using indexes. ... Merge DataFrames by indexes or columns. ... The keys, levels, and names arguments are all optional. A walkthrough of how this method fits in with other tools for combining pandas objects can be found here.
๐ŸŒ
Real Python
realpython.com โ€บ pandas-merge-join-and-concat
Combining Data in pandas With merge(), .join(), and concat() โ€“ Real Python
February 7, 2023 - In this step-by-step tutorial, you'll learn three techniques for combining data in pandas: merge(), .join(), and concat(). Combining Series and DataFrame objects in pandas is a powerful way to gain new insights into your data.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ pandas โ€บ how-to-concatenate-two-or-more-pandas-dataframes
How To Concatenate Two or More Pandas DataFrames? - GeeksforGeeks
July 23, 2025 - This helps you organize and distinguish the data more clearly by assigning a label to each DataFrame being concatenated. The resulting DataFrame will have a multi-level index that helps track the origin of each data point. This is useful when the labels are same or overlapping. ... import pandas as pd df1 = pd.DataFrame({'A': [1, 2], 'B': [3, 4]}) df2 = pd.DataFrame({'A': [5, 6], 'B': [7, 8]}) result = pd.concat([df1, df2], axis=0, keys=['First', 'Second']) print(result)
๐ŸŒ
Capital One
capitalone.com โ€บ tech โ€บ open-source โ€บ pandas-dataframe-concat
How to Concatenate Using Pandas with Examples | Capital One
The join keyword argument specifies how to handle indexes on the other axis when concatenating DataFrames. Options include the default โ€˜outerโ€™ (union of all indexes) and โ€˜innerโ€™ (intersection of indexes). The example below demonstrates the output when using the โ€˜innerโ€™ join. Note that you need to set the axis to 1 to specify where to join. ... import pandas as pd data1 = {'A': [1, 2], 'B': [3, 4]} data2 = {'A': [5, 6], 'B': [7, 8]} #Create two DataFrames with different indexes df1 = pd.DataFrame(data1, index=['a', 'b']) df2 = pd.DataFrame(data2, index=['b', 'c']) # Create a new DataFrame using the concat() method and optional join parameter result = pd.concat([df1, df2], axis=1, join='inner') print(result)
๐ŸŒ
Medium
medium.com โ€บ @whyamit404 โ€บ understanding-pandas-concat-to-combine-dataframes-41a0abe34cf4
Understanding pandas.concat() to Combine DataFrames | by whyamit404 | Medium
February 26, 2025 - Now pandas will give you fresh, clean index numbers. join: This handles what to do when DataFrames have different columns: join='outer' (default): Keeps all columns, filling missing values with NaN. join='inner': Keeps only the columns that are common in all DataFrames. Itโ€™s like deciding if you want the complete picture or just the overlapping details. 2.1. Concatenating DataFrames Vertically (Default axis=0)
Find elsewhere
๐ŸŒ
Data Science Discovery
discovery.cs.illinois.edu โ€บ guides โ€บ Combining-DataFrames โ€บ Combining-DataFrames-by-Concatenation
Combining DataFrames by Concatenation - Data Science Discovery
July 25, 2022 - If you wanted to combine the two DataFrames horizontally, you can use .concat() with the parameter axis=1. This might be useful if data extends across multiple columns in the two DataFrames.
๐ŸŒ
Python Data Science Handbook
jakevdp.github.io โ€บ PythonDataScienceHandbook โ€บ 03.06-concat-and-append.html
Combining Datasets: Concat and Append | Python Data Science Handbook
Here we'll take a look at simple concatenation of Series and DataFrames with the pd.concat function; later we'll dive into more sophisticated in-memory merges and joins implemented in Pandas.
๐ŸŒ
Data Carpentry
datacarpentry.github.io โ€บ python-ecology-lesson โ€บ 05-merging-data
Data Analysis and Visualization in Python for Ecologists: Combining DataFrames with Pandas
February 21, 2024 - We can use the concat function in pandas to append either columns or rows from one DataFrame to another.
๐ŸŒ
Analytics Vidhya
analyticsvidhya.com โ€บ home โ€บ how to concatenate two or more pandas dataframes?
How To Concatenate Two or More Pandas DataFrames?
September 6, 2024 - Pandasโ€™s `append` function allows us to append one DataFrame to another. It concatenates the rows of the second DataFrame to the end of the first DataFrame.
๐ŸŒ
Medium
medium.com โ€บ @whyamit404 โ€บ understanding-pandas-concat-for-columns-93b730b11e33
Understanding pandas.concat() for Columns | by whyamit404 | Medium
February 26, 2025 - Simply put, pandas.concat() is a function that allows you to combine multiple DataFrames or Series either vertically (stacked) or horizontally (side-by-side). Think of it like gluing datasets together, with control over how they align.
๐ŸŒ
APXML
apxml.com โ€บ courses โ€บ essential-numpy-pandas โ€บ chapter-10-combining-dataframes-pandas โ€บ concatenating-dataframes
Concatenating DataFrames (pd.concat)
One of the most straightforward ways to combine DataFrames is by concatenation. Think of it like stacking pieces of paper (your DataFrames) either one on top of the other (appending rows) or side-by-side (adding columns). Pandas provides the pd.concat() function for this purpose.
Top answer
1 of 3
155

call concat and pass param axis=1 to concatenate column-wise:

In [5]:

pd.concat([df_a,df_b], axis=1)
Out[5]:
        AAseq Biorep  Techrep Treatment     mz      AAseq1 Biorep1  Techrep1  \
0  ELVISLIVES      A        1         C  500.0  ELVISLIVES       A         1   
1  ELVISLIVES      A        1         C  500.5  ELVISLIVES       A         1   
2  ELVISLIVES      A        1         C  501.0  ELVISLIVES       A         1   

  Treatment1  inte1  
0          C   1100  
1          C   1050  
2          C   1010  

There is a useful guide to the various methods of merging, joining and concatenating online.

For example, as you have no clashing columns you can merge and use the indices as they have the same number of rows:

In [6]:

df_a.merge(df_b, left_index=True, right_index=True)
Out[6]:
        AAseq Biorep  Techrep Treatment     mz      AAseq1 Biorep1  Techrep1  \
0  ELVISLIVES      A        1         C  500.0  ELVISLIVES       A         1   
1  ELVISLIVES      A        1         C  500.5  ELVISLIVES       A         1   
2  ELVISLIVES      A        1         C  501.0  ELVISLIVES       A         1   

  Treatment1  inte1  
0          C   1100  
1          C   1050  
2          C   1010  

And for the same reasons as above a simple join works too:

In [7]:

df_a.join(df_b)
Out[7]:
        AAseq Biorep  Techrep Treatment     mz      AAseq1 Biorep1  Techrep1  \
0  ELVISLIVES      A        1         C  500.0  ELVISLIVES       A         1   
1  ELVISLIVES      A        1         C  500.5  ELVISLIVES       A         1   
2  ELVISLIVES      A        1         C  501.0  ELVISLIVES       A         1   

  Treatment1  inte1  
0          C   1100  
1          C   1050  
2          C   1010  
2 of 3
11

Thanks to @EdChum I was struggling with same problem especially when indexes do not match. Unfortunatly in pandas guide this case is missed (when you for example delete some rows)

import pandas as pd
t=pd.DataFrame()
t['a']=[1,2,3,4]
t=t.loc[t['a']>1] #now index starts from 1

u=pd.DataFrame()
u['b']=[1,2,3] #index starts from 0

#option 1
#keep index of t
u.index = t.index 

#option 2
#index of t starts from 0
t.reset_index(drop=True, inplace=True)

#now concat will keep number of rows 
r=pd.concat([t,u], axis=1)
๐ŸŒ
Kanaries
docs.kanaries.net โ€บ topics โ€บ Python โ€บ pandas-concat-two-dataframes
How to concat two Pandas DataFrames: Explained! โ€“ Kanaries
August 18, 2023 - Learn how to concatenate Pandas DataFrames vertically and horizontally, merge DataFrames with different columns and ignore index using the concat() function.
๐ŸŒ
Saturn Cloud
saturncloud.io โ€บ blog โ€บ pandas-how-to-concatenate-dataframes-with-different-columns
Pandas How to concatenate dataframes with different columns | Saturn Cloud Blog
November 2, 2023 - As a data scientist or software ... is a common operation in data processing, and Pandas provides a function called concat() that allows you to combine two or more dataframes....
๐ŸŒ
Built In
builtin.com โ€บ articles โ€บ pandas-concat
Pandas concat() Function in Python With Examples | Built In
The pandas.concat() function concatenates and combines multiple DataFrames or Series into a single, unified DataFrame or Series. Our expert explains what you need to know.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ pandas-concat-function-in-python
pandas.concat() function in Python - GeeksforGeeks
June 24, 2025 - pandas.concat() function concatenate two or more pandas objects like DataFrames or Series along a particular axis. It is especially useful when combining datasets either vertically (row-wise) or horizontally (column-wise).