[Python] Why std(skipna=False) and std(skipna=True) yield different results even when there...

Discussão em 'Python' iniciado por Stack, Março 19, 2025.

  1. Stack

    Stack Membro Participativo

    I have a pandas Series s, and when I call s.std(skipna=True) and s.std(skipna=False) I get different results even when there are no NaN/null values in s, why? Did I misunderstand the skipna parameter? I'm using pandas 1.3.4

    import pandas as pd

    s = pd.Series([10.0]*4800000, index=range(4800000), dtype="float32")

    # No NaN/null in the Series
    print(s.isnull().any()) # False
    print(s.isna().any()) # False

    # Why the code below prints different results?
    print(s.std(skipna=False)) # 0.0
    print(s.std(skipna=True)) # 0.61053276

    Continue reading...

Compartilhe esta Página