PacktPublishing/Python-for-Finance-Second-Edition

This code is not working in chapter 2

Opened this issue · 0 comments

import pandas as pd
import numpy as np
np.random.seed(123) # fix the random numbers
x=np.arange(1, 10.1, .25)**2
n=np.size(x)
y = pd.Series(x + np.random.randn(n))
bad=np.array([4,13,14,15,16,20,30])
x[bad] = np.nan # missing code is np.nan
methods = ['linear', 'quadratic', 'cubic']
df = pd.DataFrame({m: x.interpolate(method=m) for m in methods})
df.plot()