【发布时间】:2014-04-02 13:51:20
【问题描述】:
我试图在每日收盘价的数据框中选择每个星期五。我阅读并尝试了this link 中的建议,具体来说:
Fridays = df[df.index.weekday == 4] #Fridays
但我收到以下错误:
AttributeError: 'Index' object has no attribute 'weekday'
<class 'pandas.core.frame.DataFrame'>
我认为问题在于 Python 无法将索引中的字符串识别为日期,但我不知道为什么。 DataFrame 如下所示:
1993-04-08 3387.83
1993-04-12 3420.79
感谢任何帮助。
【问题讨论】:
标签: python indexing pandas dataframe weekday