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: The current behaviour of 'Series.argmin' is deprecated, use 'idxmin' instead. #601

Open
xgdgsc opened this issue May 24, 2019 · 2 comments

Comments

@xgdgsc
Copy link

xgdgsc commented May 24, 2019

Problem Description

I get FutureWarning: The current behaviour of 'Series.argmin' is deprecated, use 'idxmin' instead. when running pyfolio using latest numpy.

pf.create_returns_tear_sheet(returns)

Please provide the full traceback:

/home/sgao/anaconda3/lib/python3.7/site-packages/numpy/core/fromnumeric.py:56: FutureWarning:


The current behaviour of 'Series.argmin' is deprecated, use 'idxmin'
instead.
The behavior of 'argmin' will be corrected to return the positional
minimum in the future. For now, use 'series.values.argmin' or
'np.argmin(np.array(values))' to get the position of the minimum
row.

Versions

  • Pyfolio version: 0.9.2
  • Python version: 3.7 from anaconda
  • Pandas version: '0.24.2'
  • Matplotlib version: '3.0.3'
@mstrofbass
Copy link

Changing line 893 in pyfolio/timeseries.py from:

valley = np.argmin(underwater)  # end of the period

to:

valley = underwater.idxmin()   # end of the period

appears to fix the problem. I put some simple logs to confirm that it works for what I was running through it but I have zero confidence that I know enough about what's going on to put my name on a pull request.

@letianzj
Copy link

letianzj commented Jul 3, 2020

Can someone pull in the request? Thanks.
New numpy already changed the behaviour to returning positional index. Should be a quick fix by using idxmin or adding something like below to be backward compatible
if isinstance(valley, int): valley = underwater.index[valley]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants