Mean Variance Optimization - PORTFOLIO OPTIMIZATION

Hello, can please help me, im trying to recreate portfolio optimization on my comp working in pycharm. but i getting this error message every time. I even copied and past each file from yours exercise but same error.

here are the files: - script - rf

Traceback (most recent call last):
File “/PycharmProjects/Mean-variance-optimization/", line 29, in
weights, returns, risks = optimal_portfolio(returns_quarterly[1:])
File "
/PycharmProjects/Mean-variance-optimization/", line 43, in optimal_portfolio
returns = np.transpose(returns.as_matrix())
File "
***********/PycharmProjects/Mean-variance-optimization/venv/lib/python3.8/site-packages/pandas/core/”, line 5274, in getattr
return object.getattribute(self, name)
AttributeError: ‘DataFrame’ object has no attribute ‘as_matrix’

Hey mate

change .as_matrix to .to_numpy() , from what ive figured .as_matrix has withered away.

1 Like