คำอธิบาย
ใช้ property DateTimeIndex.microsecond ดึงค่าไมโครวินาที (0-999,999) ของแต่ละ timestamp
ตัวอย่างโค้ด
import pandas as pd
datetimeindex = pd.date_range('2021-10-20 02:30:50', periods=6, tz='Australia/Sydney', freq='us')
print("DateTimeIndex...\n", datetimeindex)
print("DateTimeIndex frequency...\n", datetimeindex.freq)
print("\nGetting the microseconds..\n", datetimeindex.microsecond)
ผลลัพธ์
DateTimeIndex...
DatetimeIndex(['2021-10-20 02:30:50+11:00', '2021-10-20 02:30:50.000001+11:00',
'2021-10-20 02:30:50.000002+11:00', '2021-10-20 02:30:50.000003+11:00',
'2021-10-20 02:30:50.000004+11:00', '2021-10-20 02:30:50.000005+11:00'],
dtype='datetime64[ns, Australia/Sydney]', freq='U')
Getting the microseconds..
Int64Index([0, 1, 2, 3, 4, 5], dtype='int64')
ความถี่ (freq) ที่เกี่ยวข้อง
'us'หรือ'U'= ไมโครวินาที'ns'หรือ'N'= นาโนวินาที.microsecondคืนค่า 0-999999,.nanosecondคืนค่า 0-999999999