2024-04-26 17:57:29 发布
网友
我有一个np时间戳数组:
ts = np.range(5) In [34]: ts Out[34]: array([0, 1, 2, 3, 4])
我有一个pandas DataFrame:
pandas DataFrame
保证data的索引是ts的子集。我想生成以下数据帧:
data
ts
res: 0 10 1 nan 2 nan 3 10 4 10
所以我希望索引是ts,值是data。{t{t>存在于
您正在寻找reindex函数。在
例如:
data.reindex(index=ts)
输出:
您正在寻找reindex函数。在
例如:
输出:
^{pr2}$相关问题 更多 >
编程相关推荐