如何获取两个 pandas pd.Timestamp 对象之间的平均值或中值?
为了计算两个 pd.Timestamp 实例之间的平均值,将它们相减获得 pd.Timedelta,然后将该 Timedelta 对象添加到第一个(较小的)时间戳:
timestamp_mean.py
t1 = pd.Timestamp('now')
t2 = pd.Timestamp('now')
mean_timestamp = t1 + ((t2 - t1) / 2)If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow