DEPR: deprecate Series/DataFrame.compound
State: closed

xref https://github.com/pandas-dev/pandas/issues/18262

Not sure if we need to point to an alternative in the deprecation warning. I can put the exact "formula" for what we are currently calculating, but I don't know enough from finance to know if that is actually good to point to (eg I don't directly see that formula on the first google hit https://en.wikipedia.org/wiki/Compound_interest)

Labels:
name: Deprecate
description: Functionality to remove in pandas

Comments:
I'm +1 on deprecating this, as a scalar verion of compount is not particularly useful (I'm an economist).

But also, compound interests arrays can be a bit tricky to calulate in some cases. Would there be acceptance for adding e.g. ``cumpct_change`` to mirror ``cumsum`` etc.?

Thanks, good to have feedback of somebody who knows something about it! :)

> Would there be acceptance for adding e.g. cumpct_change to mirror cumsum etc.?

Personally, I would say, that looks a a bit too specific (but yeah, I would never use it myself). Maybe we should think about making it easier to do generic cumulative operations.
> Maybe we should think about making it easier to do generic cumulative operations.

Actually, that's `expanding` no?
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26405?src=pr&el=h1) Report
> Merging [#26405](https://codecov.io/gh/pandas-dev/pandas/pull/26405?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/3b24fb678672ecb6ef24a1915c49f3cf815d5556?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/26405/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/26405?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #26405      +/-   ##
==========================================
+ Coverage   91.69%   91.69%   +<.01%     
==========================================
  Files         174      174              
  Lines       50743    50745       +2     
==========================================
+ Hits        46527    46529       +2     
  Misses       4216     4216
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.2% <100%> (ø)` | :arrow_up: |
| #single | `41.19% <0%> (-0.14%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26405?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/26405/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `93.49% <100%> (+0.14%)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/26405/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `78.94% <0%> (-10.53%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/26405/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.02% <0%> (-0.12%)` | :arrow_down: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/26405/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `90.7% <0%> (+0.1%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26405?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26405?src=pr&el=footer). Last update [3b24fb6...9a3ac10](https://codecov.io/gh/pandas-dev/pandas/pull/26405?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26405?src=pr&el=h1) Report
> Merging [#26405](https://codecov.io/gh/pandas-dev/pandas/pull/26405?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/9c5165e26260483ae64300c4d98939bf575aab7e?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/26405/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/26405?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #26405      +/-   ##
==========================================
- Coverage   91.69%   91.68%   -0.01%     
==========================================
  Files         174      174              
  Lines       50739    50741       +2     
==========================================
+ Hits        46523    46524       +1     
- Misses       4216     4217       +1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.19% <100%> (ø)` | :arrow_up: |
| #single | `41.16% <0%> (-0.16%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26405?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/26405/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `93.49% <100%> (+0.14%)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/26405/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `78.94% <0%> (-10.53%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/26405/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.02% <0%> (-0.12%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26405?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26405?src=pr&el=footer). Last update [9c5165e...4d40284](https://codecov.io/gh/pandas-dev/pandas/pull/26405?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

Added whatsnew
Hey guys, as you mentioned there is no alternative suggested. I've been using this method for a while, what would be the shortest/cleanest way to replace this method on a Series?

Thanks!
it’s just

(1 + s).prod() - 1