Python 时间序列index.day属性错误

Python 时间序列index.day属性错误,python,pandas,ipython,time-series,Python,Pandas,Ipython,Time Series,我试图通过使用时间序列获取日、月、年或季度(任何内容)。但我一直收到以下错误: AttributeError:“Int64Index”对象没有属性“day” 我正在为熊猫使用v14 我看过: scd.index将提供以下信息: In [85]: scd.index Out[85]: Int64Index([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 2

我试图通过使用时间序列获取日、月、年或季度(任何内容)。但我一直收到以下错误:

AttributeError:“Int64Index”对象没有属性“day”

我正在为熊猫使用v14 我看过:

scd.index将提供以下信息:

In [85]:

scd.index
Out[85]:
Int64Index([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...], dtype='int64')
但是,当我试图引用那天时,它给了我一个错误

In [98]:scd.index.day
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-98-718bfa312e31> in <module>()
----> 1 scd.index.day[:-1]

AttributeError: 'Int64Index' object has no attribute 'day'

您的索引是数据类型
Int64
而不是
datetime
timestamp
,请说明您如何加载数据以及数据来自何处,您链接到的笔记本显示的不同代码感谢您的回复。希望我上面的编辑有助于澄清问题。我看不出您在哪里将索引设置为类似日期时间的列,您可以访问现有列的day属性,或者将其中一列设置为您的索引,然后访问它的day属性
df.index.day
仅在索引具有日期时间值时才起作用(它试图获取索引的“day”部分,而不是某个列)。但是,正如上面的评论所解释的,你没有这个部分,只有一个带整数值的索引。你可以做的是:
pd.DatetimeIndex(raw_data['SCD\u LV\u YMD')。day
Beautiful Joris,这是我需要的修复!感谢所有人的输入。我从所有人那里学到了东西。
In [98]:scd.index.day
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-98-718bfa312e31> in <module>()
----> 1 scd.index.day[:-1]

AttributeError: 'Int64Index' object has no attribute 'day'
raw_data = pd.read_csv('C:\Users\davidlopez\Desktop\Folders\Standard Reports\HR Reports\ERI RNO DATA\DAVEPHIS\\davephis\davefy14.txt',
                       names=[
                                'NM_EMP_LST',
                                'NM_EMP_FST',
                                'NAT_ACTN_1_3',
                                'NAT_ACTN_2_3',
                                'ACTN_DT',
                                'ACTN_YMD',
                                'TYPE_APNT',
                                'ORG_LEV2',
                                'ORG_LEV3',
                                'ORG_LEV4',
                                'ORG_LEV5',
                                'MR_NBR',
                                'POS_OFF_TTL',
                                'APNT_NA_ACTN',
                                'APNT_AUTH_1',
                                'APNT_YMD',
                                'SCD_CSR_YMD',
                                'SCD_LV_YMD',
                                'SSNO',
                                'TENURE_GROUP'], parse_dates=['ACTN_DT','ACTN_YMD','APNT_YMD','SCD_CSR_YMD','SCD_LV_YMD'])