Python| Pandas Timedelta.asm8
Python是一种用于进行数据分析的出色语言,主要是因为以数据为中心的Python包的奇妙生态系统。 Pandas 就是其中之一,它使导入和分析数据变得更加容易。
Timedelta 是datetime.timedelta
的子类,行为方式类似。它是 python 的datetime.timedelta
的 pandas 等价物,在大多数情况下可以与它互换。 Timedelta.asm8
中的pandas.Timedelta
属性用于返回一个 numpy timedelta64数组视图。
Syntax: Timedelta.asm8
Parameters: None
Returns: numpy timedelta64 array view
代码#1:
# importing pandas as pd
import pandas as pd
# Create the Timedelta object
td = pd.Timedelta('3 days 06:05:01.000030')
# Print the Timedelta object
print(td)
print(td.asm8)
输出:
3 days 06:05:01.000030
281101000030000 nanoseconds
代码#2:
# importing pandas as pd
import pandas as pd
# Create the Timedelta object
td = pd.Timedelta('1 days 7 hours')
# Print the Timedelta object
print(td)
print(td.asm8)
输出:
1 days 07:00:00
111600000000000 nanoseconds
代码#3:
# importing pandas as pd
import pandas as pd
import datetime
# Create the Timedelta object
td = pd.Timedelta(datetime.timedelta(days = 3, hours = 7, seconds = 8))
# Print the Timedelta object
print(td)
print(td.asm8)
输出:
3 days 07:00:08
284408000000000 nanoseconds