I need to calculate pct_change for Bitcoin (BTC) and Ether (ETH) prices from this data frame:
The formula I want to use is basically:
initial = df['Close'][0]
final = df.iloc[-1]['Close']
df['Performance'] = (100*(df[symbol] - initial)/initial)
The problem is, I can't figure out how to keep BTC and ETH calculations separate. How can I do this? I tried making two separate data frames, one for BTC and one for ETH and then using the formula, but I got this error:
A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead
What can I do instead?