0

I pip installed pyfolio and was getting the same error.

After some digging I found this function :

def get_max_drawdown_underwater(underwater):

... And that the valley variable was ill-defined resulting in the returned variable being of type nump.int64 and not timestamp as stated in the function description.

vallay = underwater.index[np.argmin(underwater)] # np.argmin(underwater)

fixed this by changing line 893 in file timeseries.py

/usr/local/lib/python3.6/dist-packages/pyfolio/timeseries.py

how to change it on google colab or in jupyter ??

  • 1
    Sorry—what is the context here? – Arya McCarthy Feb 23 '21 at 04:49
  • I'm sorry for the typo, I just want to change a little bit of code in the timeseries.py file – Dwijaya Maleh Feb 23 '21 at 04:53
  • 1
    You need to provide more information. At this point, it seems that your question is: “How do I write Python files?” – Arya McCarthy Feb 23 '21 at 04:56
  • 1
    Are you saying that you had to change something inside a third party module to get the result you desired? And so you're asking how to make that change on Google Colab? – CryptoFool Feb 23 '21 at 05:27
  • @CryptoFool yes – Dwijaya Maleh Feb 23 '21 at 05:29
  • 1
    If you have to change a third party module to get it to work, you're either doing something wrong, or the library is, IMO, not worth relying on. I'm an old timer who has been doing this since before Python was invented. I've never once resorted to changing a Python module to get what I wanted. Maybe you've got to do this, but I'd be very hestant to do so. If you do need do this, I wouldn't be surprised if this is something you can't fix on Google Colab. – CryptoFool Feb 23 '21 at 05:30
  • I just want to make changes like here [attributeerror-numpy-int64-object-has-no-attribute-to-pydatetime](https://stackoverflow.com/questions/63554616/attributeerror-numpy-int64-object-has-no-attribute-to-pydatetime) – Dwijaya Maleh Feb 23 '21 at 05:33
  • 1
    I was looking, and Colab seems to have the notion of a filesystem around your code. So what you might have to do is add a copy of the source for the entire `pyfolio` module in your own source tree. Then, when you do `import pyfolio`, you'll be importing your own version of the module. – CryptoFool Feb 23 '21 at 05:33
  • 1
    I get what you want to do. I just don't know if you can edit the code for installed modules in Colab. If you can, then go for it. But since you're asking how to go about it, and my Googling didn't find an answer, maybe you can't. – CryptoFool Feb 23 '21 at 05:36
  • 1
    I just found this. Does this help you? https://stackoverflow.com/questions/56917299/how-to-edit-google-colaboratory-libraries. This seems to be addressing your issue. – CryptoFool Feb 23 '21 at 05:37

0 Answers0