The code below suggests that pandas may be much slower than numpy, at least in the specifi case of the function clip(). What is surprising is that making a roundtrip from pandas to numpy and back to pandas, while performing the calculations in numpy, is still much faster than doing it in pandas.
Shouldn't the pandas function have been implemented in this roundabout way?
In [49]: arr = np.random.randn(1000, 1000)
In [50]: df=pd.DataFrame(arr)
In [51]: %timeit np.clip(arr, 0, None)
100 loops, best of 3: 8.18 ms per loop
In [52]: %timeit df.clip_lower(0)
1 loops, best of 3: 344 ms per loop
In [53]: %timeit pd.DataFrame(np.clip(df.values, 0, None))
100 loops, best of 3: 8.4 ms per loop
.valuesmake that direct comparison.