Skip to content

Lack of default zero for QuadPrecision() causes pandas failure #83

@ejeffrey

Description

@ejeffrey

If I construct a pandas DataFrame with one or more QuadPrecision series, the default "print" display fails. The last frame of the stack trace is shown here:

File ~/.virtualenvs/py3/lib/python3.13/site-packages/pandas/core/array_algos/take.py:592, in _take_preprocess_indexer_and_fill_value(arr, indexer, fill_value, allow_fill, mask)
    587         mask_info = mask, needs_masking
    588         if not needs_masking:
    589             # if not, then depromote, set fill_value to dummy
    590             # (it won't be used but we don't want the cython code
    591             # to crash when trying to cast it to dtype)
--> 592             dtype, fill_value = arr.dtype, arr.dtype.type()
    594 return dtype, fill_value, mask_info

TypeError: function missing required argument 'value' (pos 1)

The arr.dtype is QuadPrecDType(backend='sleef') so this is effectively calling the default constructor. I haven't followed the logic of why it is doing this, but according to the comment it is just preparing a dummy value of the correct type.

One could argue that pandas should supply the argument. However, not all types that might be used by pandas can be constructed from a zero -- for instance strings. On the other hand, almost all scalar data types, such as python str, int, and float, as well as numpy numeric data types allow default construction with the implied value zero.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions