data/file_level_aggregation.py
def aggregate(self, date: str, time_range: int = 30
    ) -> Union[pd.DataFrame, None]:
        """Aggregates the historical file level signals on input date.

        This function takes in a date string, a integer indicating the time
        range. It will aggregate all the historical file level signals before
        the given date, within the time range.

        Args:
            date: A str indicating the date to aggregate.
            time_range: A integer indicating how many days to look backward.

        Returns:
            A pandas DataFrame that holds the aggregated file level signals.
        """
        start_date = datetime.fromisoformat(date) - timedelta(
            days=time_range+1)
        end_date = datetime.fromisoformat(date) - timedelta(
            days=1)
        new_start_date = datetime(start_date.year, start_date.month,
                                  start_date.day)
        new_end_date = datetime(end_date.year, end_date.month, end_date.day, 23,
                                59, 59)
        pr_closed_timestamp = self._file_level_data['pull request closed time']\
            .apply(to_timestamp)
        start_date_timestamp = to_timestamp(new_start_date.isoformat() + 'Z')
        end_date_timestamp = to_timestamp(new_end_date.isoformat() + 'Z')
        data_in_range = self._file_level_data[
            (pr_closed_timestamp >= start_date_timestamp) &
            (end_date_timestamp >= pr_closed_timestamp)]
        if data_in_range.empty:
            return None
        aggregated_data = data_in_range.groupby(['file name', 'repo name']).agg(
            lambda x: list(x))
        flatten_columns = ['issue comments msg', 'approved reviewers',
                           'review comments msg']
        for column in flatten_columns:
            aggregated_data[column] = aggregated_data[column]\
                .apply(self.flatten_lst)
        aggregated_data['author'] = aggregated_data['author']\
            .apply(set).apply(list)
        for column in PULL_REQUEST_RELATED_COLUMNS:
            aggregated_data[column] = aggregated_data[column]\
                .apply(self.remove_nan)
        for column in FILE_RELATED_COLUMNS:
            aggregated_data[column] = aggregated_data[column]\
                .apply(self.remove_nan)

        return aggregated_data
Aggregates the historical file level signals on input date.

        This function takes in a date string, a integer indicating the time
        range. It will aggregate all the historical file level signals before
        the given date, within the time range.

        Args:
            date: A str indicating the date to aggregate.
            time_range: A integer indicating how many days to look backward.

        Returns:
            A pandas DataFrame that holds the aggregated file level signals.
        
Aggregates the historical file level signals on input date.
This function takes in a date string, a integer indicating the time
range. It will aggregate all the historical file level signals before
the given date, within the time range.
Aggregates the historical file level signals on input date . This function takes in a date string a integer indicating the time range . It will aggregate all the historical file level signals before the given date within the time range .
def aggregate(self, date: str, time_range: int = 30
    ) -> Union[pd.DataFrame, None]:
        start_date = datetime.fromisoformat(date) - timedelta(
            days=time_range+1)
        end_date = datetime.fromisoformat(date) - timedelta(
            days=1)
        new_start_date = datetime(start_date.year, start_date.month,
                                  start_date.day)
        new_end_date = datetime(end_date.year, end_date.month, end_date.day, 23,
                                59, 59)
        pr_closed_timestamp = self._file_level_data['pull request closed time']\
            .apply(to_timestamp)
        start_date_timestamp = to_timestamp(new_start_date.isoformat() + 'Z')
        end_date_timestamp = to_timestamp(new_end_date.isoformat() + 'Z')
        data_in_range = self._file_level_data[
            (pr_closed_timestamp >= start_date_timestamp) &
            (end_date_timestamp >= pr_closed_timestamp)]
        if data_in_range.empty:
            return None
        aggregated_data = data_in_range.groupby(['file name', 'repo name']).agg(
            lambda x: list(x))
        flatten_columns = ['issue comments msg', 'approved reviewers',
                           'review comments msg']
        for column in flatten_columns:
            aggregated_data[column] = aggregated_data[column]\
                .apply(self.flatten_lst)
        aggregated_data['author'] = aggregated_data['author']\
            .apply(set).apply(list)
        for column in PULL_REQUEST_RELATED_COLUMNS:
            aggregated_data[column] = aggregated_data[column]\
                .apply(self.remove_nan)
        for column in FILE_RELATED_COLUMNS:
            aggregated_data[column] = aggregated_data[column]\
                .apply(self.remove_nan)
        return aggregated_data
def aggregate ( self , date : str , time_range : int = 30 ) -> Union [ pd . DataFrame , None ] : start_date = datetime . fromisoformat ( date ) - timedelta ( days = time_range + 1 ) end_date = datetime . fromisoformat ( date ) - timedelta ( days = 1 ) new_start_date = datetime ( start_date . year , start_date . month , start_date . day ) new_end_date = datetime ( end_date . year , end_date . month , end_date . day , 23 , 59 , 59 ) pr_closed_timestamp = self . _file_level_data [ 'pull request closed time' ] . apply ( to_timestamp ) start_date_timestamp = to_timestamp ( new_start_date . isoformat ( ) + 'Z' ) end_date_timestamp = to_timestamp ( new_end_date . isoformat ( ) + 'Z' ) data_in_range = self . _file_level_data [ ( pr_closed_timestamp >= start_date_timestamp ) & ( end_date_timestamp >= pr_closed_timestamp ) ] if data_in_range . empty : return None aggregated_data = data_in_range . groupby ( [ 'file name' , 'repo name' ] ) . agg ( lambda x : list ( x ) ) flatten_columns = [ 'issue comments msg' , 'approved reviewers' , 'review comments msg' ] for column in flatten_columns : aggregated_data [ column ] = aggregated_data [ column ] . apply ( self . flatten_lst ) aggregated_data [ 'author' ] = aggregated_data [ 'author' ] . apply ( set ) . apply ( list ) for column in PULL_REQUEST_RELATED_COLUMNS : aggregated_data [ column ] = aggregated_data [ column ] . apply ( self . remove_nan ) for column in FILE_RELATED_COLUMNS : aggregated_data [ column ] = aggregated_data [ column ] . apply ( self . remove_nan ) return aggregated_data
Aggregates the historical file level signals on input date.
Aggregates the historical file level signals on input date .
"""Aggregates the historical file level signals on input date.

        This function takes in a date string, a integer indicating the time
        range. It will aggregate all the historical file level signals before
        the given date, within the time range.

        Args:
            date: A str indicating the date to aggregate.
            time_range: A integer indicating how many days to look backward.

        Returns:
            A pandas DataFrame that holds the aggregated file level signals.
        """
A pandas DataFrame that holds the aggregated file level signals.
A pandas DataFrame that holds the aggregated file level signals .
self
date
str
A str indicating the date to aggregate.
A str indicating the date to aggregate .
time_range
int
A integer indicating how many days to look backward.
A integer indicating how many days to look backward .