Python Pandas TimedeltaIndex.rename
Python是一种进行数据分析的伟大语言,主要是因为以数据为中心的Python包的奇妙生态系统。Pandas就是这些包中的一个,它使导入和分析数据变得更加容易。
Pandas TimedeltaIndex.rename()函数在索引上设置新名称。它默认为返回新的索引。
语法: TimedeltaIndex.rename(name, inplace=False)
参数:无
name : [str 或 list] 要设置的名称
inplace:如果为真,就地变异。
返回 :新的索引(同一类型和类别…等)[如果是原位,则返回无]
示例#1:使用TimedeltaIndex.rename()函数来重命名给定的TimedeltaIndex对象。
输出 :
现在我们将使用TimedeltaIndex.rename()函数来重命名tidx对象。
输出 :
正如我们在输出中看到的,TimedeltaIndex.rename()函数已经返回了一个新的索引,并设置了TimedeltaIndex对象的名称属性。
示例#2:使用TimedeltaIndex.rename()函数来重命名给定的TimedeltaIndex对象。
输出 :
现在我们将使用TimedeltaIndex.rename()函数来重命名tidx对象。
输出 :
正如我们在输出中看到的,TimedeltaIndex.rename()函数已经返回了一个新的索引,并设置了TimedeltaIndex对象的名称属性。