我有这个:
1900-01-01 00:00:00.003
1900-01-01 00:00:00.003
1900-01-01 00:00:00.007
1900-01-01 00:00:00.007
1900-01-01 00:00:00.011
1900-01-01 00:00:00.011
1900-01-01 00:00:00.015
1900-01-01 00:00:00.015
我像这样将df转换为日期时间:
x = pd.to_datetime(df['Time'], format='%H:%M:%S.%f')
我正在尝试创建一个微秒的累积数组,如下所示:
003
003
007
007
011
011
015
015
但是我收到以下消息:
'Series' object has no attribute 'microsecond'
我正在尝试这样的x.microsecond
IIUC:
x = pd.to_datetime(df['Time'], format='%Y-%m-%d %H:%M:%S.%f')
x.dt.microseconds
用途:
x = pd.to_datetime(df['Time'], format='%H:%M:%S.%f').dt.strftime('%f').astype(int) / 1000
print (x)
0 3.0
1 3.0
2 7.0
3 7.0
4 11.0
5 11.0
6 15.0
7 15.0
Name: Time, dtype: float64