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 in Python by Kiran
8 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 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
1,212 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
• 56,160 points
192 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
• 56,160 points
286 views
0 votes
1 answer
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,700 points
72 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,700 points
640 views
0 votes
2 answers
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,550 points
960 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 in Python by SA
• 1,030 points
86 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
• 56,160 points
131 views