python - 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)
解决方案
推荐阅读
- python - 生成 N 个伪随机整数的列表,从特定范围中提取,列表总和为特定值
- c# - C#:标记“-”处的语法错误:IL_0029:从源代码构建时的 ldc.r8-inf
- elasticsearch - ELASTICSEARCH - 如何在布尔字段中获取聚合?
- r - 在 R 中创建一个 for 循环,其中迭代次数是来自 UI 输入的反应变量
- python-3.x - 使用 selenium、python 的 Web 抓取表
- javascript - UTC 如何与 Javascript 和错误时间的计算机一起工作?
- django - Django重定向显示所有细节
- java - 如何从 USB 摄像头开始、停止和保存录制
- mysql - 创建 SQL 触发器
- sql - 寻求帮助修复一个小的 sql 查询