pyfolio
pyfolio copied to clipboard
FutureWarning: The current behaviour of 'Series.argmin' is deprecated, use 'idxmin' instead.
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'
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.
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]