dataframe_builders.py 文件源码

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

项目:betterself 作者: jeffshek 项目源码 文件源码
def round_timestamp_to_sleep_date(timeseries):
        """
        Not my proudest function ... this isn't as efficient as it could be, but struggling
        with some pandas syntax to find the perfect pandas one-line

        This can be much more performant, but need time to sit down and figure it out
        """
        sleep_dates = []
        for value in timeseries:
            if value.hour < SLEEP_CUTOFF_TIME:
                result = value - pd.DateOffset(days=1)
            else:
                result = value

            sleep_dates.append(result)

        index = pd.DatetimeIndex(sleep_dates)
        return index
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号