WillKoehrsen / Data-Analysis

Data Science Using Python

Home Page:https://medium.com/@williamkoehrsen/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error : it seems that related_queries[search] is NoneType in changepoint_date_analysis

antoinecomp opened this issue · comments

Hi there ! I just found what I think is a little error:

# same method but with a search term
msci.changepoint_date_analysis(search = 'Microsoft profit')

...

Top Related Queries: 

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-21-4e46f891db49> in <module>
      1 # same method but with a search term
----> 2 msci.changepoint_date_analysis(search = 'Microsoft profit')

~\Documents\Programming\Luxurynsight\Finance\stocker.py in changepoint_date_analysis(self, search)
    779 
    780             print('\n Top Related Queries: \n')
--> 781             print(related_queries[search]['top'].head())
    782 
    783             print('\n Rising Related Queries: \n')

AttributeError: 'NoneType' object has no attribute 'head'

Another error was raised when running another query:

Top Related Queries: 

        query  value
0  msci index    100
1  msci china     67
2  msci world     56
3     msci 指數     28
4     msci 中國     28

 Rising Related Queries: 

        query  value
0     msci 中國    130
1  msci world     50
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-26-080452be5a00> in <module>
      1 # same method but with a search term
----> 2 msci.changepoint_date_analysis(search = 'msci')

~\Documents\Programming\Luxurynsight\Finance\stocker.py in changepoint_date_analysis(self, search)
    787             trends = trends.resample('D')
    788 
--> 789             trends = trends.reset_index(level=0)
    790             trends = trends.rename(columns={'date': 'ds', search: 'freq'})
    791 

C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\resample.py in __getattr__(self, attr)
     95             return self[attr]
     96 
---> 97         return object.__getattribute__(self, attr)
     98 
     99     @property

AttributeError: 'DatetimeIndexResampler' object has no attribute 'reset_index'

i have the same issue.
microsoft.changepoint_date_analysis(search..........