[Python] What's wrong with numpy_nullable and NaNs?

Discussão em 'Python' iniciado por Stack, Abril 14, 2025.

  1. Stack

    Stack Membro Participativo

    Doing the same operation using plain numpy, the numpy_nullable backend and the pyarrow backend shows that numpy_nullable behaves differently than the other two and in a rather counter-intuitive way.

    >>> import pandas as pd
    >>> sr = pd.Series([1.5, 0.0])
    >>> (sr / sr).max()
    1.0
    >>> sr = pd.Series([1.5, 0.0]).convert_dtypes()
    >>> (sr / sr).max()
    <NA>
    >>> sr = pd.Series([1.5, 0.0]).convert_dtypes(dtype_backend='pyarrow')
    >>> (sr / sr).max()
    1.0


    Is there a good reason, or at least an explanation, for this inconsistent behavior? Is there a way around it or should we simply avoid the numpy_nullable backend?

    Continue reading...

Compartilhe esta Página