Scipy fmin_slsqp error “failed in converting 8th argument `g' of _slsqp.slsqp to C/Fortran array”

前端 未结 2 1001
心在旅途
心在旅途 2021-01-13 09:53

I have seen this question or a variant asked elsewhere e.g.

Scipy error using optimization module. Failure converting array to fortran

http://numpy-discussio

2条回答
  •  失恋的感觉
    2021-01-13 10:35

    Hi I had the same error with the following:

    def ptf_returns(weights,returns):
    
        return pd.DataFrame(np.array(returns).T*(weights)).T.mean().mean()
    

    When I add the following it works:

    def ptf_returns(weights,returns):
    
        return float(pd.DataFrame(np.array(returns).T*(weights)).T.mean().mean())
    

    The bug seems to be oriented around the type() of the response.

提交回复
热议问题