In the codebase I'm working in, I see the following
df1 = some pandas dataframe (one of the columns is quantity)
df1_subset = df1[df1.quantity == input_quantity].copy()
I am wondering why the .copy()
is needed here? Doesn't df1_subset = df1[df1.quantity == input_quantity]
make df1_subset
a copy and not a reference?
I saw in why should I make a copy of a data frame in pandas that a reference would be returned, but I think this is outdated?