Python| Pandas TimedeltaIndex.union()
Python是一种用于进行数据分析的出色语言,主要是因为以数据为中心的Python包的奇妙生态系统。 Pandas就是其中之一,它使导入和分析数据变得更加容易。
Pandas TimedeltaIndex.union()函数是 TimedeltaIndex 对象的专用联合。它结合了具有相同 DateOffset 的重叠范围,将比 Index.union 快得多
Syntax : TimedeltaIndex.union(other)
Parameters :
other : TimedeltaIndex or array-like
Return : Index or TimedeltaIndex
示例 #1:使用 TimedeltaIndex.union()函数查找两个 TimedeltaIndex 对象的集合并集。
Python3
# importing pandas as pd
import pandas as pd
# Create the first TimedeltaIndex object
tidx1 = pd.TimedeltaIndex(start ='11 days 22:11:12.001124',
periods = 5, freq ='T', name ='New_object')
# Create the second TimedeltaIndex object
tidx2 = pd.TimedeltaIndex(start ='11 days 22:14:12.001124',
periods = 5, freq ='T', name ='New_object')
# Print the first TimedeltaIndex object
print(tidx1)
# Print the second TimedeltaIndex object
print(tidx2)
Python3
# find the union
tidx1.union(tidx2)
Python3
# importing pandas as pd
import pandas as pd
# Create the first TimedeltaIndex object
tidx1 = pd.TimedeltaIndex(start ='1 days 02:00:12.001124',
periods = 5, freq ='D', name ='Koala')
# Create the second TimedeltaIndex object
tidx2 = pd.TimedeltaIndex(start ='3 days 02:00:12.001124',
periods = 5, freq ='D', name ='Koala')
# Print the first TimedeltaIndex object
print(tidx1)
# Print the second TimedeltaIndex object
print(tidx2)
Python3
# find the union
tidx1.union(tidx2)
输出 :
现在我们将使用 TimedeltaIndex.union()函数来找到两个对象的集合并集
Python3
# find the union
tidx1.union(tidx2)
输出 :
正如我们在输出中看到的,TimedeltaIndex.union()函数返回了一个对象,其中包含 tidx1 和 tidx2 的联合。示例 #2:使用 TimedeltaIndex.union()函数查找两个 TimedeltaIndex 对象的集合并集。
Python3
# importing pandas as pd
import pandas as pd
# Create the first TimedeltaIndex object
tidx1 = pd.TimedeltaIndex(start ='1 days 02:00:12.001124',
periods = 5, freq ='D', name ='Koala')
# Create the second TimedeltaIndex object
tidx2 = pd.TimedeltaIndex(start ='3 days 02:00:12.001124',
periods = 5, freq ='D', name ='Koala')
# Print the first TimedeltaIndex object
print(tidx1)
# Print the second TimedeltaIndex object
print(tidx2)
输出 :
现在我们将使用 TimedeltaIndex.union()函数来找到两个对象的集合并集
Python3
# find the union
tidx1.union(tidx2)
输出 :
正如我们在输出中看到的,TimedeltaIndex.union()函数返回了一个对象,其中包含 tidx1 和 tidx2 的联合。