Python Pandas DatetimeIndex.microsecond
Python是一种进行数据分析的伟大语言,主要是因为以数据为中心的Python包的奇妙生态系统。Pandas就是这些包中的一个,它使导入和分析数据变得更加容易。
Pandas DatetimeIndex.microsecond属性会输出一个索引对象,其中包含DatetimeIndex对象的每个条目中存在的微秒值。
语法: DatetimeIndex.microsecond
返回:包含微秒的索引。
示例#1:使用DatetimeIndex.microsecond属性来查找DatetimeIndex对象中存在的微秒值。
# importing pandas as pd
import pandas as pd
# Create the DatetimeIndex
# Here 'U' represents microseconds
didx = pd.DatetimeIndex(start ='2014-08-01 10:05:45', freq ='U',
periods = 5, tz ='Asia/Calcutta')
# Print the DatetimeIndex
print(didx)
输出 :
现在我们要找到DatetimeIndex对象中的所有微秒值。
# find all the microsecond values
# present in the object
didx.microsecond
输出 :
正如我们在输出中所看到的,该函数返回了一个Index对象,其中包含DatetimeIndex对象的每个条目中存在的微秒值。
示例#2:使用DatetimeIndex.microsecond属性来查找DatetimeIndex对象中存在的微秒值。
# importing pandas as pd
import pandas as pd
# Create the DatetimeIndex
didx = pd.DatetimeIndex(['2014-08-01 10:05:45.000001 + 05:30',
'2014-08-01 10:05:45.000010 + 05:30'])
# Print the DatetimeIndex
print(didx)
输出 :
现在我们要找到DatetimeIndex对象中的所有微秒值。
# find all the microsecond values
# present in the object
didx.microsecond
输出 :
正如我们在输出中所看到的,该函数返回了一个Index对象,其中包含DatetimeIndex对象的每个条目中存在的微秒值。