AttributeError: (“module 'pandas' has no attribute 'rolling_std'” - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: AttributeError: (“module 'pandas' has no attribute 'rolling_std'” (/thread-21210.html) |
AttributeError: (“module 'pandas' has no attribute 'rolling_std'” - Mariana136 - Sep-19-2019 Hello, I have an error ocurred in a code in Python- Jupyter. I am new in python. The error ocurred where it's used pd.rolling_std. I don't know why it doesn't work beacuse I used this code before and it worked perfect. Anyone knows what happen? I saw the answer to the same question but it doesn't work for me. Thank you Here is the code: import pandas as pd import numpy as np def score(SeriesTemps, window): # normalization SeriesTempsNorm=(SeriesTemps-SeriesTemps.mean())/(SeriesTemps[:-1].std() + 1) # "+ 1" to avoid division by 0 #model rollingStd = SeriesTempsNorm.apply(lambda x : pd.rolling_std(x,window=window), axis = 0) scoreSeason = rollingStd.iloc[-1] / rollingStd.iloc[window-1] #division of the last element by the first no NaN (offset du to the computation of the rolling std) scoreYear = rollingStd.iloc[-1] / rollingStd.iloc[:-1].mean() #mean variance as denominator def mergeScore(scoreSeason, scoreYear): # we take the right score if scoreSeason == np.inf: # if the Seasonal score is inf, their is no seasonnality effect, we take the score over the past year to avoid inf score return scoreYear else: return min(scoreSeason,scoreYear) # else it might be a seasonnality effect, then we take the season score score = scoreSeason.combine(other = scoreYear, func= lambda x, y : mergeScore(x,y)) return score def groupedScore(SeriesTemps): # normalization SeriesTempsNorm=(SeriesTemps-SeriesTemps.mean())/(SeriesTemps[:-1].std() + 1) # "+ 1" to avoid division by 0 #model return SeriesTempsNorm[1:].std() / SeriesTempsNorm[:-1].std() def scores_computation(SeriesTemps,group,window): if group < 6: # compute the score with concidering seasonnality return score(SeriesTemps,window) else: # compute the score without considering seasonnality return groupedScore(SeriesTemps) RE: AttributeError: (“module 'pandas' has no attribute 'rolling_std'” - Larz60+ - Sep-20-2019 show error, verbatim RE: AttributeError: (“module 'pandas' has no attribute 'rolling_std'” - Mariana136 - Sep-23-2019 Sorry. Here is the error:
RE: AttributeError: (“module 'pandas' has no attribute 'rolling_std'” - Larz60+ - Sep-23-2019 rolling_std has been depreciated from pandas, can still be used but syntax has changed see: https://pandas.pydata.org/pandas-docs/stable/whatsnew/index.html RE: AttributeError: (“module 'pandas' has no attribute 'rolling_std'” - Mariana136 - Sep-23-2019 I tried to replace rollingStd = SeriesTempsNorm.apply(lambda x : pd.rolling_std(x,window=window), axis = 0)with rollingStd = SeriesTempsNorm.apply(lambda x : SeriesTemps.rolling(window=window).std(x), axis = 0)but still doesn't work.. |