Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FutureWarning Setting an item of incompatible dtype is deprecated #602

Open
bsdice opened this issue Sep 3, 2024 · 1 comment
Open

FutureWarning Setting an item of incompatible dtype is deprecated #602

bsdice opened this issue Sep 3, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@bsdice
Copy link

bsdice commented Sep 3, 2024

Yo,

I like to use -X dev and I get this warning on Python 3.11.9 with Pandas 2.2.1:

pypfopt/hierarchical_portfolio.py:135: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise an error in a future version of pandas. Value '[0.22193172 0.22193172]' has dtype incompatible with int64, please explicitly cast to a compatible dtype first. w[first_cluster] *= alpha # weight 1

Which I think can be fixed in https://github.com/robertmartin8/PyPortfolioOpt/blob/master/pypfopt/hierarchical_portfolio.py#L120

by writing

w = pd.Series(1.0, index=ordered_tickers)

Thanks, and great library. For the 50 people on the planet knowing how to wield its power. ;-)

@bsdice bsdice added the bug Something isn't working label Sep 3, 2024
@BeachGuy007
Copy link

BeachGuy007 commented Sep 5, 2024

I am seeing the same warning.

\pypfopt\hierarchical_portfolio.py:138: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise an error in a future version of pandas. Value '[0.41629061 0.41629061 0.41629061 0.41629061 0.41629061 0.41629061]' has dtype incompatible with int64, please explicitly cast to a compatible dtype first. w[first_cluster] *= alpha # weight 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants