首页 > 解决方案 > Panda Rolling Max:为什么我不断收到“无属性”错误

问题描述

我正在尝试用熊猫找到 52、104、156 周的最高点。我试过rolling_max,但我认为它已经过时了。所以我检查了熊猫文档并尝试了Series和DataFrame。但我不断收到无属性错误。我怎样才能解决这个问题?

AttributeError: module 'pandas_datareader.data' has no attribute 'Series'
AttributeError: module 'pandas_datareader.data' has no attribute 'DataFrame'
AttributeError: module 'pandas_datareader.data' has no attribute 'rolling'
import pandas as pd
import numpy as np
import yfinance as yf
import datetime as dt
from pandas_datareader import data as pdr

yf.pdr_override()

stock = input("Enter a stock ticker symbol: ")
print(stock)

startyear = 2019
startmonth = 1
startday = 1

start = dt.datetime(startyear, startmonth, startday)

now = dt.datetime.now()

df = pdr.get_data_yahoo(stock, start, now)

print(df)


df[52 - Week - High] = pdr.Series.rolling(min_periods=1, window=52*5, center=False).max()
df[104 - Week - High] = pdr.Series.rolling(min_periods=1, window=104*5, center=False).max()
df[156 - Week - High] = pdr.Series.rolling(min_periods=1, window=156*5, center=False).max()

print(df)

标签: pythonpandasyahoo-finance

解决方案


推荐阅读