Super learner
This user is a Super Learner. To become a Super Learner, you need to reach Level 8.
Posted on:

27 Dec 2023

0

use .loc vs not using .loc?

Let's take a look at the following codes:

# First Code

temp = df_purchase_predictors[df_purchase_predictors['Brand'] == 1]
temp.loc[:, 'Revenue Brand 1'] = temp['Price_1'] * temp['Quantity']
temp

 

 versus:

# Second Code

temp1 = df_purchase_predictors[df_purchase_predictors['Brand'] == 1]
temp1['Revenue Brand 1'] = temp1['Price_1'] * temp1['Quantity']
temp1

The only difference is using loc or not.

and it returned exactly the same table.

is there any difference?

 

0 answers ( 0 marked as helpful)

Submit an answer