DataFrame对行列求和并添加新行

    技术2023-04-10  88

    python DataFrame对行列求和并添加新行或列

    计算各行数据总和并作为新行添加到末尾

    week_time_group_table.loc['Col_sum'] = week_time_group_table.apply(lambda x: x.mean())

    示例效果:

    计算各列数据总和并作为新列添加到末尾

    df['row_sum'] = df.apply(lambda x: x.sum(), axis=1)

    参考文章:https://blog.csdn.net/weixin_30563917/article/details/97577431

    Processed: 0.010, SQL: 9