utils.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:empyrical 作者: quantopian 项目源码 文件源码
def get_utc_timestamp(dt):
    """
    Returns the Timestamp/DatetimeIndex
    with either localized or converted to UTC.
    Parameters
    ----------
    dt : Timestamp/DatetimeIndex
        the date(s) to be converted
    Returns
    -------
    same type as input
        date(s) converted to UTC
    """

    dt = pd.to_datetime(dt)
    try:
        dt = dt.tz_localize('UTC')
    except TypeError:
        dt = dt.tz_convert('UTC')
    return dt
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号