Python Pandas - 使用整数输入来返回 Timedelta 对象中的微秒
如需返回 Timedelta 对象中的纳秒数,请使用 timedelta.microseconds 属性。首先,导入所需的库 −
import pandas as pd
TimeDeltas 是 Python 的标准 datetime 库,它使用不同的表示形式 timedelta。使用单位“us”设置微秒的整数输入。创建 Timedelta 对象
timedelta = pd.Timedelta(55, unit ='us')
显示 Timedelta
print("Timedelta...\n", timedelta)返回微秒值
timedelta.microseconds
示例
以下为代码
import pandas as pd
# TimeDeltas is Python’s standard datetime library uses a different representation timedelta’s
# set integer input for microseconds using unit 'us'
# create a Timedelta object
timedelta = pd.Timedelta(55, unit ='us')
# display the Timedelta
print("Timedelta...\n", timedelta)
# return the microseconds value
res = timedelta.microseconds
# display the microseconds
print("\nTimedelta (microseconds value)...\n", res)输出
这将生成以下代码
Timedelta... 0 days 00:00:00.055000 Timedelta (microseconds value)... 55
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP