table_formatters.py 文件源码

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

项目:PyBloqs 作者: manahl 项目源码 文件源码
def _modify_dataframe(self, df):
        """Add row to dataframe, containing numbers aggregated with self.operator."""
        if self.total_columns == []:
            columns = df.columns
        else:
            columns = self.total_columns
        if self.operator is not OP_NONE:
            last_row = self.operator(df[df.applymap(np.isreal)])
            last_row = last_row.fillna(0.)
            last_row[~last_row.index.isin(columns)] = ''
        else:
            last_row = pd.Series('', index=df.columns)
        last_row.name = self.row_name
        # Appending kills index name, save now and restore after appending
        index_name = df.index.name
        df = df.append(last_row)
        df.index.name = index_name
        return df
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号