What’s the best way to sum all values in a Pandas dataframe? [duplicate]

Updated for Pandas 0.24+

df.to_numpy().sum()

Prior to Pandas 0.24+

df.values

Is the underlying numpy array

df.values.sum()

Is the numpy sum method and is faster

Leave a Comment