Back to Community
ValueError: Inferred frequency None from passed values does not conform to passed frequency B

Running

alphalens.tears.create_returns_tear_sheet(factor_data)  

throws the error

ValueError: Inferred frequency None from passed values does not conform to passed frequency B  

When I go into the source code, I see that this comes out of

alphalens.performance.factor_weights(factor_data, True, False, False)  

which throws


ValueError: Inferred frequency None from passed values does not conform to passed frequency D  

So I believe the problem is in factor_weights. And so, I copy the code from factor_weights over and run it in my local computer, doing

factor_weights(factor_data, True, False, False)  

but it runs just fine.

I have this 'Inferred frequency' problem quite often. Would love to hear how to fix this. So far, I have tried resetting the frequency of my index:

factor_data = factor_data.unstack().asfreq(None).stack()  
# or also  
factor_data = factor_data.unstack().asfreq('B').stack()  
# or even  
factor_data = factor_data.unstack().asfreq('D').stack()  

but no dice.

1 response

I've come across this a few times myself and wanted to post here for anyone else running into this issue.

It sounds like this code is being run in a local environment in which case the ValueError could be a function of running a version of pandas that is not compatible with Alphalens. Per this comment , the most recent version of pandas that is compatible with Alphalens is version 0.20.3.