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

时间:2014-09-09 07:45:41

标签: python pandas ipython time-series

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

  

AttributeError:' Int64Index'对象没有属性'

;

我正在使用v14作为熊猫 我看过the cookbook tutorial

scd = raw_data[['SCD_LV_YMD']]

     SCD_LV_YMD
0    2000-09-23
1    1999-10-23
2    1999-10-23
3    1989-04-12
4    1989-04-12
5    1989-05-30
6    1989-05-30
7    1989-05-30
8    1996-01-14
9    1996-01-14

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'

我使用pd.read.csv引入了数据并解析了日期。

他们最初看起来像19891023

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'])

0 个答案:

没有答案