Skip to content

Instantly share code, notes, and snippets.

@bmweiner
Last active September 30, 2017 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmweiner/1b7b837feb280057918ccd1e83f0898b to your computer and use it in GitHub Desktop.
Save bmweiner/1b7b837feb280057918ccd1e83f0898b to your computer and use it in GitHub Desktop.
Compare equality of two pandas dataframes
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
char num mix extra
a 1 h 1
b 2 i 1
c 3 3532 0
d 4 k 0
e 5 42 1
f 6 m 1
g 7 n 1
char num mix
a 1 h
b i
a 3 3532
d 4 k
e 2 42
f 6 m
{'columns': [('Columns Match', False),
('df1 Columns',
array(['char', 'num', 'mix', 'extra'], dtype=object)),
('df2 Columns', array(['char', 'num', 'mix'], dtype=object)),
('df1 Only', array(['extra'], dtype=object)),
('df2 Only', array([], dtype=object))],
'setup': [('Filename 1', 'data1.csv'),
('Filename 2', 'data2.csv'),
('Description', 'Comparison of df1 and df2'),
('Absolute Numeric Tolerance', 0.0001),
('Relative Numeric Tolerance', 0)],
'shapes': [('Shapes Match', False),
('df1 Shape', (7, 4)),
('df2 Shape', (6, 3))],
'values': [('Values Match', False),
('Max Shape', (7, 4)),
('Possible Values', 28),
('Excluded Values', 10),
('Shape Compared', (6, 3)),
('Total Values Compared', 18),
('Total Values Matched', 15),
('Total Values Not Matched', 3)]}
i j col1 col2 val1 val2
1 1 num num 2
4 1 num num 5 2.0
2 0 char char c a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment