Skip to content

Add Triangle.bfill() #1029

@genedan

Description

@genedan

Description

Pandas DataFrame.bfill() can be mirrored to fill in NaNs in a backward 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': [np.nan, 600, np.nan, 800, np.nan, 1000, 1100, 1200, 1300, 1400]
    },
    origin='origin',
    development='development',
    columns=['paid'],
    cumulative=True
)
tri

          12      24      36     48
1985     NaN   600.0     NaN  800.0
1986     NaN  1000.0  1100.0    NaN
1987  1200.0  1300.0     NaN    NaN
1988  1400.0     NaN     NaN    NaN
tri.bfill(axis=3)

          12      24      36     48
1985   600.0   600.0   800.0  800.0
1986  1000.0  1000.0  1100.0    NaN
1987  1200.0  1300.0     NaN    NaN
1988  1400.0     NaN     NaN    NaN
tri.bfill(axis=4)

          12      24      36     48
1985  1200.0   600.0  1100.0  800.0
1986  1200.0  1000.0  1100.0    NaN
1987  1200.0  1300.0     NaN    NaN
1988  1400.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