# f500.loc[f500.loc[:,"previous_rank"].notnull()] break-down into 2 line for understanding
# This is to filter-out null values from column `previous_rank`
# Will return `Series` containing `True` where value is null otherwise `False`
bool_idx = f500["previous_rank"].notnull()
# Now use above boolean index `bool_idx` to get rows from `f500` dataframe that has non-null values.
# Will return dataframe; `previously_ranked` is same as `f500` but with only non-null values
previously_ranked = f500[bool_idx]
# Here we are subtracting `rank` column from the `previous_rank` column of `previously_ranked` dataframe.
# It will store difference between `previous_rank` and `rank` as series
rank_change = previously_ranked["previous_rank"] - previously_ranked["rank"]
# At last adding new column to original dataframe `f500`
f500["rank_change"] = rank_change