Python是进行数据分析的一种出色语言,主要是因为以数据为中心的python软件包具有奇妙的生态系统。 Pandas是其中的一种,使导入和分析数据更加容易。
Pandas TimedeltaIndex.ndim属性返回基础数据的维数,根据定义为1。
用法: TimedeltaIndex.ndim
返回:对象的尺寸
示例1:采用TimedeltaIndex.ndim属性以找出给定TimedeltaIndex对象的尺寸。
# importing pandas as pd
import pandas as pd
# Create the TimedeltaIndex object
tidx = pd.TimedeltaIndex(start ='1 days 02:00:12.001124', periods = 5,
freq ='N', name ='Koala')
# Print the TimedeltaIndex
print(tidx)
输出:
现在我们将找到tidx对象的尺寸。
# return the dimension of the tidx object
tidx.ndim
输出:
正如我们在输出中看到的,TimedeltaIndex.ndim属性已返回1,指示tidx对象的尺寸为1。根据定义,TimedeltaIndex对象的尺寸为1。
示例2:采用TimedeltaIndex.ndim属性以找出给定TimedeltaIndex对象的尺寸。
# importing pandas as pd
import pandas as pd
# Create the TimedeltaIndex object
tidx = pd.TimedeltaIndex(data =['-1 days 2 min 3us 10ns', '1 days 06:05:01.000030',
'-1 days + 23:59:59.999999'])
# Print the TimedeltaIndex
print(tidx)
输出:
现在我们将找到tidx对象的尺寸。
# return the dimension of the tidx object
tidx.ndim
输出:
正如我们在输出中看到的,TimedeltaIndex.ndim属性已返回1,指示tidx对象的尺寸为1。根据定义,TimedeltaIndex对象的尺寸为1。