[Python] Strange result when powering pandas integer series

Discussão em 'Python' iniciado por Stack, Julho 4, 2025.

  1. Stack

    Stack Membro Participativo

    The result when powering a pandas integer Series seems wrong.

    # Standard Python
    42**42
    # 150130937545296572356771972164254457814047970568738777235893533016064

    # Pandas series, float dtype
    s = pd.Series([12, 42], index=range(2), dtype=float)
    s**42
    # 0 2.116471e+45
    # 1 1.501309e+68
    # dtype: float64

    # Pandas series, integer dtype
    s = pd.Series([12, 42], index=range(2), dtype=int)
    s**42
    # 0 0
    # 1 4121466560160202752
    # dtype: int64


    How come?

    Continue reading...

Compartilhe esta Página