sotrue
sotrue

Reputation: 341

Choosing between numpy.interp vs scipy.interpolate.interp1d (with kind='linear')

I'm trying to choose between numpy.interp vs scipy.interpolate.interp1d (with kind='linear' of course). I realize they have different interfaces but that doesn't matter much to me (I can code around either interface). I'm wondering whether there are other differences I should be aware of. Thanks.

Upvotes: 23

Views: 12460

Answers (2)

ev-br
ev-br

Reputation: 26090

Numpy.interp does not handle complex-valued data or ndim>1, while scipy.interp1d does both. OTOH, numpy's interpolator is much faster (and is likely faster still in more recent numpy version).

Upvotes: 26

Moritz
Moritz

Reputation: 5418

While numpy returns an array with discrete datapoints, 'interp1d' returns a function. You can use the generated function later in your code as often as you want. Furthermore, you can choose other methods than linear interpoationn

Upvotes: 10

Related Questions