It seems like nothing is worth it.
Firstly, df_a.cumsum()by default axis=0(Pandas has no idea of ββsumming the entire DataFrame in one call), and the default NumPy call is axis=None. Thus, setting the axis in one operation and effectively smoothing the other, you compare apples to oranges.
However, there are three challenges you could compare:
>>> np.cumsum(df_a, axis=0)
>>> df_a.cumsum()
>>> val.cumsum(axis=0)
val NumPy, .values .
, IPython, %prun :
>>> %prun -q -T pdcumsum.txt df_a.cumsum()
>>> val = df_a.values
>>> %prun -q -T ndarraycumsum.txt val.cumsum(axis=0)
>>> %prun -q -T df_npcumsum.txt np.cumsum(df_a, axis=0)
-T , , . :
df_a.cumsum(): 186 , 0,022 . 0,013 numpy.ndarray.cumsum(). ( , NaNs, nancumsum() , , , ). .val.cumsum(axis=0): 5 , 0,020 . ( ).np.cumsum(df_a, axis=0): 204 , 0,026 . , Pandas NumPy Pandas, , NumPy.
, %timeit, 1 , %time, %prun; , . , , , , Pandas, NumPy. , np.ndarray.cumsum(), Pandas . , Pandas , , , .
- Wes McKinney,
, , , .
, .
: NumPy , ndarray.cumsum(), np.cumsum(), . , , - .
:
>>> pd.__version__, np.__version__
('0.22.0', '1.14.0')