I have a many large Pandas series of "cost slopes" representing a linear function `f` given in an painful form. Here is a much smaller example:

```
slopes = Series({'-inf': 10, -200: 60, 0: 0, 200: 1, 'inf': 10})

-inf    10
-200    60
0        0
200      1
inf     10

```

(0, 0) is always in the Series, and the slopes represent the piecewise "marginal cost" as you move from zero either direction

```
f(-200) = 12000  # abs(-200) * 60
f(-100) = 6000  # abs(-100) * 60
f(0) = 0
f(100) = 100  # 100 * 1
f(200) = 200  # 200 * 1
f(300) = 1200  # 200 * 1 + (300-200) * 10

```

as the series are large and are called many times I was hoping to put this in a form where I can use Numpy's `interp` or `piecewise` or Pandas `interpolate` for speed rather than building `for` loops.

I think [`piecewise`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.piecewise.html) might be the solution, but I'm not sure how to convert and handle the `inf`? Maybe there is a cleaner way?