은 다음과 같습니다변환 날짜는
date tag
0 2015-07-30 19:19:35-04:00 E7RG6
1 2016-01-27 08:20:01-05:00 ER57G
2 2015-11-15 23:32:16-05:00 EQW7G
3 2016-07-12 00:01:11-04:00 ERV7G
4 2016-02-14 00:35:21-05:00 EQW7G
5 2016-03-01 00:08:59-05:00 EQW7G
6 2015-06-19 07:15:06-04:00 ER57G
7 2016-09-08 18:17:53-04:00 ER5TT
8 2016-09-03 01:53:45-04:00 EQW7G
9 2015-11-30 09:31:02-05:00 ER57G
10 2016-03-03 22:28:26-05:00 ES5TG
11 2016-02-11 10:39:24-05:00 E5P7G
12 2015-03-16 07:18:47-04:00 ER57G
...
[11015 rows x 2 columns]
date datetime64[ns, America/New_York]
tag object
dtype: object
나는 인덱스로 열 '날짜'를 설정하려고 해요 :
df = df.set_index(pd.DatetimeIndex(df['date']))
다음과 같은 오류를 얻을 수 내가 this을 상담 한
File "pandas/tslib.pyx", line 3753, in pandas.tslib.tz_localize_to_utc (pandas/tslib.c:64516)
pytz.exceptions.AmbiguousTimeError: Cannot infer dst time from Timestamp('2015-11-01 01:38:12'), try using the 'ambiguous' argument
(팬더 0.19를 사용),하지만, 난 여전히이 오류를 통해 일을 할 수 있어요. 예를 들어,
df = df.set_index(pd.DatetimeIndex(df['date']), ambiguous='infer')
수율 :
File "pandas/tslib.pyx", line 3703, in pandas.tslib.tz_localize_to_utc (pandas/tslib.c:63553)
pytz.exceptions.AmbiguousTimeError: Cannot infer dst time from 2015-11-01 01:38:12 asthere are no repeated times
인덱스에 날짜 열을 변환하는 방법에 대한 조언이 크게 감상 할 수있다. 당신의 dtype
열의가 이미 datetime
경우
'df.set_index (df ['date '], inplace = True)'그냥 작동하지 않습니까? – EdChum
예! 그것은 완벽하게 작동했습니다. @EdChum 감사합니다. – Kappa