def generate_summary(df):
level_counts = df.Level.value_counts().to_dict()
zlist = list(zip(*[('<a href="#info">Items Processed Succesfully</a>', level_counts.get('INFO', 0)),
('<a href="#warning">Items Skipped Due to a Warning</a>', level_counts.get('WARNING', 0)),
('<a href="#error">Items Skipped Due to an Error</a>', level_counts.get('ERROR', 0))]))
level_counts = pd.Series(zlist[1], index=zlist[0])
level_counts.name = "Count"
info_counts = df.query("Level == 'INFO'").Message.value_counts().to_dict()
zlist = list(zip(*[('No Action', info_counts.get('SKIP', 0)),
('Update', info_counts.get('UPDATE', 0)),
('Create', info_counts.get('CREATE', 0))]))
info_counts = pd.Series(zlist[1], index=zlist[0])
info_counts.name = "Count"
warning_counts = df.query("Level == 'WARNING'")['Msg Type'].value_counts()
warning_counts.name = "Count"
error_counts = df.query("Level == 'ERROR'")['Msg Type'].value_counts()
error_counts.name = "Count"
return level_counts, info_counts, warning_counts, error_counts
评论列表
文章目录