# Rank_change in tutorial - different approaches should have yielded the same results (ie. min)

My Code:

``````

# Approach 1

rank_change = f500.loc[:, "rank"] - f500.loc[:,"previous_rank"]
rank_change_desc = rank_change.describe()
f500["rank_change"] = rank_change
minf500Approach1 = f500["rank_change"].min()

# Approach 2

f500_rank = f500.loc[:,"rank"]
f500_prev_rank = f500.loc[:,"previous_rank"]
rank_changed =  f500_prev_rank - f500_rank
minf500Approach2 = rank_changed.min()

# Approach 3

rank_changeded  =   f500.loc[:,"rank"]  - f500.loc[:,"previous_rank"]
rank_changeded.describe()

minf500Approach3 = rank_changeded.min()

print(minf500Approach1)
print(minf500Approach2)
print(minf500Approach3)

``````

What I expected to happen:

the min value of rank change for approach 1, 2 and 3 are to be exactly the same because
they are doing the same thing.

What actually happened:

``````
minf500approach1 and minf500approach3 are the same but minf500approach2 does not match them.

``````

The output is:
-226.0
-199.0
-226.0

Got it - approaches 1 and 3 are rank - prev rank else approach 2 is prev rank - rank

solved

1 Like