Error calling pyfolio due to `AttributeError: 'Series' object has no attribute 'iteritems'`

Course Name: Financial Time Series Analysis for Trading, Section No: 26, Unit No: 6, Unit type: Notebook

Running the code, in the very last cell,

pf.create_simple_tear_sheet(data_test['strategy_returns'].resample('1D').sum())

I am thrown the following error:

AttributeError: 'Series' object has no attribute 'iteritems'

I think there is an issue with pyfolio because of the pandas version used in the notebook: pyfolio still calls .iteritems(), but pandas removed Series.iteritems() and DataFrame.iteritems() in pandas 2.0. More specifically, the pandas docs mark iteritems as deprecated in 1.5 and removed in 2.0.

Thank you for bringing this to our attention, we will look into it and get back to you.

Thanks for highlighting this Benjamin.

You are right, the issue arises due to incompatibility between pyfolio and newer Python versions. The code has now been updated to ensure it works in a compatible environment.

Appreciate you flagging this.