What is the difference between pd.concat(frames) and pd.concat(frames, key[])?

0 votes
I came across two command while I was finding out how to concatenate Pandas dataframe: pd.concat(frames) and pd.concat(frames, key[]). Can someone tell me what is the difference between these two?
May 14, 2019 in Python by Kiran
76 views

1 answer to this question.

0 votes

Both the codes are used to concatenate the dataframes. 

pd.concatenate(frames)

This code will take dataframes in the frames list and concatenate them forming a new dataframe.

pd.concatenate(frames, key[])

This code will also concatenate the dataframes but the difference is that this code will add certain keys to the newly formed database to identify those dataframes. This is how the data is stored:

../_images/merging_concat_keys.png

Here, is the key to dataframe df1, y is the key to dataframe df2, z is the key to dataframe df3.

answered May 14, 2019 by John

Related Questions In Python

0 votes
1 answer

What is the difference between list and tuple?

Lists are mutable(values can be changed) whereas ...READ MORE

answered May 4, 2018 in Python by aayushi
• 750 points
2,305 views
0 votes
1 answer

What is the difference between Python and IPython?

There are few differences between Python and ...READ MORE

answered Jul 26, 2018 in Python by Priyaj
• 57,530 points
962 views
0 votes
1 answer

What is the difference between re.search and re.match?

The theoritical approach can be this way, re.match is ...READ MORE

answered Aug 10, 2018 in Python by Priyaj
• 57,530 points
2,058 views
+1 vote
1 answer

What is the difference between range and xrange functions in Python 2.X?

xrange only stores the range params and ...READ MORE

answered Aug 22, 2018 in Python by Priyaj
• 57,530 points
568 views
0 votes
1 answer

How to rename columns in pandas (Python)?

It is easy by just adding ".columns" ...READ MORE

answered Apr 30, 2018 in Data Analytics by DeepCoder786
• 1,720 points
253 views
0 votes
1 answer

What is the Difference in Size and Count in pandas (python)?

The major difference is size includes NaN ...READ MORE

answered Apr 30, 2018 in Data Analytics by DeepCoder786
• 1,720 points
899 views
0 votes
2 answers

Replacing a row in pandas data.frame

key error. I love python READ MORE

answered Feb 18, 2019 in Data Analytics by anonymous
4,275 views
0 votes
1 answer

Converting a pandas data-frame to a dictionary

Emp_dict=Employee.to_dict('records') You can directly use the 'to_dict()' function ...READ MORE

answered May 23, 2018 in Data Analytics by Bharani
• 4,560 points
2,518 views
0 votes
1 answer

What is the key difference between self in ruby and self in python?

Ruby and Python are actually very different languages (although ...READ MORE

answered Jul 30, 2019 in Python by Mohammad
• 3,210 points
65 views
+1 vote
2 answers

What is the difference between classes and labels in machine learning?

Classes and Labels both are almost same things ...READ MORE

answered Apr 3, 2019 in Python by SA
• 1,050 points
213 views