Skip to content

TypeError when calling Triangle.fillna() with value=None #1025

Description

@genedan

Are you on the latest chainladder version?

  • Yes, this bug occurs on the latest version.

Describe the bug in words

I'm currently working on this, it's a quick fix. The default value to argument value in Triangle.fillna() is None, but trying to call Triangle.fillna() without arguments leads to a TypeError.

How can the bug be reproduced?

import chainladder as cl

clrd = cl.load_sample('clrd')
clrd.fillna()
Traceback (most recent call last):
  File "/home/ubuntu/Repos/chainladder-python/.venv/lib/python3.14/site-packages/IPython/core/interactiveshell.py", line 3699, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
    ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<ipython-input-5-c623c96317f4>", line 1, in <module>
    clrd.fillna()
    ~~~~~~~~~~~^^
  File "/home/ubuntu/Repos/chainladder-python/chainladder/core/pandas.py", line 287, in fillna
    return new_obj.fillna(value=value, inplace=True)
           ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/Repos/chainladder-python/chainladder/core/pandas.py", line 280, in fillna
    frame = self + value * 0
                   ~~~~~~^~~
TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'

What is the expected behavior?

I don't think this is something that ever worked, so removing the default argument and making it required will fix the problem without necessitating a major version change. I think we can safely classify this as a bug fix and not an API change.

It should lead to a ValueError, like it does in Pandas:

import pandas as pd
import numpy as np
df = pd.DataFrame({'a': [1, 2, 3], 'b': [4, 5, np.nan]})
df.fillna()
Traceback (most recent call last):
  File "/home/ubuntu/Repos/chainladder-python/.venv/lib/python3.14/site-packages/IPython/core/interactiveshell.py", line 3699, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
    ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<ipython-input-7-d3a028362a04>", line 1, in <module>
    df.fillna()
    ~~~~~~~~~^^
  File "/home/ubuntu/Repos/chainladder-python/.venv/lib/python3.14/site-packages/pandas/core/generic.py", line 7316, in fillna
    value, method = validate_fillna_kwargs(value, method)
                    ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/home/ubuntu/Repos/chainladder-python/.venv/lib/python3.14/site-packages/pandas/util/_validators.py", line 293, in validate_fillna_kwargs
    raise ValueError("Must specify a fill 'value' or 'method'.")
ValueError: Must specify a fill 'value' or 'method'.

There's no exception handling in this method, so it should be added.

Would you be willing to contribute this ticket?

  • Yes, absolutely!
  • Yes, but I would like some help.
  • No.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Fields

Priority

High

Effort

Low

Scope

Codebase

Projects

Status
Backlog

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions