📜  Python| Pandas TimedeltaIndex.inferred_type

📅  最后修改于: 2022-05-13 01:55:48.797000             🧑  作者: Mango

Python| Pandas TimedeltaIndex.inferred_type

Python是一种用于进行数据分析的出色语言,主要是因为以数据为中心的Python包的奇妙生态系统。 Pandas就是其中之一,它使导入和分析数据变得更加容易。

Pandas TimedeltaIndex.inferred_type属性返回应用它的对象的推断类型。

示例 #1:使用TimedeltaIndex.inferred_type属性推断 TimedeltaIndex 对象的类型。

# importing pandas as pd
import pandas as pd
  
# Create the TimedeltaIndex object
tidx = pd.TimedeltaIndex(data =['1 days 02:00:00', 
                   '1 days 06:05:01.000030', None])
  
# Print the TimedeltaIndex
print(tidx)

输出 :

现在我们将猜测给定 TimedeltaIndex 对象的类型。

# return the inferred type of the tidx object
tidx.inferred_type

输出 :

正如我们在输出中看到的, TimedeltaIndex.inferred_type属性为 tidx 对象返回了 'timedelta64' 类型。示例 #2:使用TimedeltaIndex.inferred_type属性推断 TimedeltaIndex 对象的类型。

# importing pandas as pd
import pandas as pd
  
# Create the TimedeltaIndex object
tidx = pd.TimedeltaIndex(data =['-1 days 2 min 3us', '1 days 06:05:01.000030',
                                                  '-1 days + 23:59:59.999999'])
  
# Print the TimedeltaIndex
print(tidx)

输出 :

现在我们将猜测给定 TimedeltaIndex 对象的类型。

# return the inferred type of the tidx object
tidx.inferred_type

输出 :

正如我们在输出中看到的, TimedeltaIndex.inferred_type属性为 tidx 对象返回了 'timedelta64' 类型。