I have a pandas dataframe in python and I want to generate RevenueCAGR column,
Company Name zumba pty ltd
Total Revenue;2018-06-30 17102.2
Total Revenue;2016-06-30 2111.5
RevenueCAGR 4.22897e+16
x2 = {'Total Revenue;2018-06-30' : [17012.2],
'Total Revenue;2016-06-30' : [2111.5],
'RevenueCAGR' : [422897]}
x2df = pd.DataFrame.from_dict(x2)
I am trying to get (Total Revenue;2018-06-30/Total Revenue;2016-06-30)^(1/3)-1.
I tried
df['RevenueCAGR'] = np.power(df['Total Revenue;2018-06-30']/df['Total Revenue;2016-06-30'], 1/3) -1
And I got this error:
__main__:1: RuntimeWarning: invalid value encountered in power
How do you get column wise operations in python to take to the power of a float?
If your dataframe is structured correctly, your code will work: