Skip to content

Add Triangle.ffill() #1030

@genedan

Description

@genedan

Description

Pandas DataFrame.ffill() can be mirrored to fill NaNs in a forward direction along the specified axis.

Leaving this as a proposed "Great First Contribution" as this would be easier than the proposed interpolation/extrapolation feature.

Is your feature request aligned with the scope of the package?

  • Yes, absolutely!
  • No, but it's still worth discussing.
  • N/A (this request is not a codebase enhancement).

Describe the solution you'd like, or your current workaround.

tri = cl.Triangle(
    data={
        'origin': [1985, 1985, 1985, 1985, 1986, 1986, 1986, 1987, 1987, 1988],
        'development': [1985, 1986, 1987, 1988, 1986, 1987, 1988, 1987, 1988, 1988],
        'paid': [500, np.nan, 700, np.nan, np.nan, 1000, 1100, 1200, 1300, np.nan]
    },
    origin='origin',
    development='development',
    columns=['paid'],
    cumulative=True
)
tri

          12      24      36  48
1985   500.0     NaN   700.0 NaN
1986     NaN  1000.0  1100.0 NaN
1987  1200.0  1300.0     NaN NaN
1988     NaN     NaN     NaN NaN
tri.ffill(axis=3)

          12      24      36     48
1985   500.0   500.0   700.0  700.0
1986     NaN  1000.0  1100.0 1100.0
1987  1200.0  1300.0     NaN    NaN
1988     NaN     NaN     NaN    NaN
tri.ffill(axis=4)
          12      24      36  48
1985   500.0     NaN   700.0 NaN
1986   500.0  1000.0  1100.0 NaN
1987  1200.0  1300.0     NaN NaN
1988  1200.0     NaN     NaN NaN

### Do you have any additional supporting notes?

_No response_

### Would you be willing to contribute this ticket?

- [ ] Yes, absolutely!
- [ ] Yes, but I would like some help.
- [ ] No.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Great First Contribution! 🌱Beginner friendly tickets with narrow scope and huge impact. Perfect to get your feet wet!

    Priority

    Low

    Effort

    Low

    Scope

    Codebase

    Projects

    Status
    Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions