user_conversations.py 文件源码

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

项目:facebook-message-analysis 作者: szheng17 项目源码 文件源码
def filter_by_datetime(self, start_dt=datetime.min, end_dt=datetime.max):
        """
        Returns a copy of self after filtering each conversation's messages
        to only contain messages that lie in a datetime interval and removing
        conversations with no messages in the datetime interval.

        Args:
            start_dt: A datetime object satisfying start_dt <= end_dt.
            end_dt: A datetime object satisfying start_dt <= end_dt.

        Returns:
            A UserConversations object that is equal to self after filtering
                the messages of each conversation in self.conversations to keep
                messages whose datetimes are in the closed interval
                [start_dt, end_dt]. Conversations with no messages in the
                interval are discarded.

        Raises:
            EmptyUserConversationsError: Across all conversations, there is no
                message that lies in the closed interval [start_dt, end_dt].
        """
        if start_dt > end_dt:
            raise ValueError("start_dt must be less than or equal to end_dt")
        message_filter = lambda x: x.timestamp >= start_dt and x.timestamp <= end_dt
        return self.filter_conversations(message_filter=message_filter)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号