Vidasci
Vidasci

Reputation: 101

What is the use of pd.concat's copy=True?

I read the following about the copy-parameter in pandas.concat function documentation:

copy: bool, default True
If False, do not copy data unnecessarily.

Questions:

  1. Why would anyone want to copy data unnecessarily? (which appearantly happens because the default is True)
  2. Are there any downsides setting copy=False?

Upvotes: 8

Views: 2641

Answers (1)

Anurag Dabas
Anurag Dabas

Reputation: 24322

well see there are 2 type of copies in python

1.Deep copy

2.Shallow Copy

so basically the copy parameter in pd.concat() defines the same by default it creates a deep copy but if you overwrite its value by False it creates Shallow copy

Note:-In deep copy a exact copy is created so if you make any changes in original variable it doesn't reflect in your copy but in shallow copy it reflect in your copy because in shallow copy the data is referencing to original data

Upvotes: 7

Related Questions