# How to revert np.log(data) and data.diff()?

I have used np.log(data) and then applied data.diff() to transform my data in timeseries model. I have the predictions. How do I convert it back to normal scale?

Here is an example for your reference:

--------------------------------------------------------------------
| sales     | np.log(sales) | (np.log(sales)).diff() | predictions |
--------------------------------------------------------------------
|166.594019 | 5.115560      | -0.045918              | -0.045918   |
--------------------------------------------------------------------


Note: I have provided only one example which from index 2 as the first value after data.diff() will be null. And hence the prediction at index 1 is 0.

• mathematically log can be reversed with exp, but I don't understand the context. Commented Nov 27, 2021 at 12:17
• I need to revert it to a natural number to share forecasted sales back with my team. Commented Nov 27, 2021 at 18:15

As far as I understand the difference is $$log(s_t)-log(s_{t-1})$$, right?
$$log(s_t)-log(s_{t-1})=log\left(\frac{s_t}{s_{t-1}}\right)$$
You could use exp to go back to the regular ratio:
$$exp\left(log\left(\frac{s_t}{s_{t-1}}\right)\right)=\frac{s_t}{s_{t-1}}$$