quantopian / alphalens

Performance analysis of predictive (alpha) stock factors
http://quantopian.github.io/alphalens
Apache License 2.0
3.18k stars 1.12k forks source link

'Index' object has no attribute 'get_values #379

Open raoraozu opened 4 years ago

raoraozu commented 4 years ago

Problem Description

Hi all, I re-ran the same code which worked well before but I am getting this error since I updated my alphalens. Is there anyone who can help? Thanks!

this is the factor_data I have

image

Please provide a minimal, self-contained, and reproducible example:

al.tears.create_full_tear_sheet(
                                factor_data,
                                long_short=True,
                                group_neutral=False,
                                by_group=False,
                            )

Please provide the full traceback:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-9-04b4e6f008b9> in <module>
      3                                 long_short=True,
      4                                 group_neutral=False,
----> 5                                 by_group=False,
      6                             )# alpha_191.097

C:\ProgramData\Anaconda3\lib\site-packages\alphalens\plotting.py in call_w_context(*args, **kwargs)
     43             with plotting_context(), axes_style(), color_palette:
     44                 sns.despine(left=True)
---> 45                 return func(*args, **kwargs)
     46         else:
     47             return func(*args, **kwargs)

C:\ProgramData\Anaconda3\lib\site-packages\alphalens\tears.py in create_full_tear_sheet(factor_data, long_short, group_neutral, by_group)
    524         factor_data, group_neutral, by_group, set_context=False
    525     )
--> 526     create_turnover_tear_sheet(factor_data, set_context=False)
    527 
    528 

C:\ProgramData\Anaconda3\lib\site-packages\alphalens\plotting.py in call_w_context(*args, **kwargs)
     45                 return func(*args, **kwargs)
     46         else:
---> 47             return func(*args, **kwargs)
     48     return call_w_context
     49 

C:\ProgramData\Anaconda3\lib\site-packages\alphalens\tears.py in create_turnover_tear_sheet(factor_data, turnover_periods)
    431     if turnover_periods is None:
    432         input_periods = utils.get_forward_returns_columns(
--> 433             factor_data.columns, require_exact_day_multiple=True,
    434         ).get_values()
    435         turnover_periods = utils.timedelta_strings_to_integers(input_periods)

AttributeError: 'Index' object has no attribute 'get_values'

Please provide any additional information below:

Versions

Vinayak285 commented 4 years ago

I know this might be a little late. But the problem is that get_values() has been deprecated (around 0.25.0) and they recommend using to_numpy() function instead. So, go to your tears.py file and change the get_values() function to to_numpy() and it should work (worked in my case as I was having the same problem).

letianzj commented 3 years ago

@Vinayak285 confirmed it works in my case too. Thanks.

VoidFly commented 3 years ago

Or you can just remove the 'get_values()', it works in my case