如何使用datacompy用html编写报告输出

vcudknz3  于 2021-07-13  发布在  Java
关注(0)|答案(0)|浏览(303)

我是python新手,很抱歉这是一个转储问题,我正在比较两个csv文件并打印datacompy报告,但我需要用html编写报告输出,这样我就可以看到我正在比较的两个csv文件之间的不匹配。我知道我们可以用csv写 df.to_csv() 但在我的例子中是html。

import datacompy as dc
import pandas as pa

df1 = pa.read_csv('data1.csv')
df2 = pa.read_csv('data2.csv')

compare = dc.Compare(df1, df2, 'id')
print(compare.report())

所以下面的输出需要用html编写

DataComPy Comparison
--------------------

DataFrame Summary
-----------------

  DataFrame  Columns  Rows
0       df1        6    10
1       df2        6    10

Column Summary
--------------

Number of columns in common: 6
Number of columns in df1 but not in df2: 0
Number of columns in df2 but not in df1: 0

Row Summary
-----------

Matched on: id
Any duplicates on match values: No
Absolute Tolerance: 0
Relative Tolerance: 0
Number of rows in common: 10
Number of rows in df1 but not in df2: 0
Number of rows in df2 but not in df1: 0

Number of rows with some compared columns unequal: 2
Number of rows with all compared columns equal: 8

Column Comparison
-----------------

Number of columns compared with some values unequal: 2
Number of columns compared with all values equal: 4
Total number of values which compare unequal: 3

Columns with Unequal Values or Types
------------------------------------

       Column df1 dtype df2 dtype  # Unequal  Max Diff  # Null Diff
0      email2    object    object          1         0            0
1  profession    object    object          2         0            0

Sample Rows with Unequal Values
-------------------------------

    id              email2 (df1)             email2 (df2)
8  108  Sherrie.Ventre@gmail.com  Sherie.Ventre@gmail.com

    id profession (df1) profession (df2)
8  108   police officer    polce officer
9  109        developer    web developer

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题