compare(self, other: 'Series', align_axis: 'Axis' = 1, keep_shape: 'bool' = False, keep_equal: 'bool' = False) -> 'DataFrame | Series'
Matching NaNs will not appear as a difference.
Object to compare with.
Determine which axis to align the comparison on.
0,or'index'
0, or 'index'
1,or'columns'
1, or 'columns'
If true, all rows and columns are kept. Otherwise, only the ones with different values are kept.
If true, the result keeps values that are equal. Otherwise, equal values are shown as NaNs.
If axis is 0 or 'index' the result will be a Series. The resulting index will be a MultiIndex with 'self' and 'other' stacked alternately at the inner level.
If axis is 1 or 'columns' the result will be a DataFrame. It will have two columns namely 'self' and 'other'.
Compare to another Series and show the differences.
DataFrame.compare
Compare with another DataFrame and show differences.
>>> s1 = pd.Series(["a", "b", "c", "d", "e"])
... s2 = pd.Series(["a", "a", "c", "b", "e"])
Align the differences on columns
This example is valid syntax, but we were not able to check execution>>> s1.compare(s2) self other 1 b a 3 d b
Stack the differences on indices
This example is valid syntax, but we were not able to check execution>>> s1.compare(s2, align_axis=0) 1 self b other a 3 self d other b dtype: object
Keep all original rows
This example is valid syntax, but we were not able to check execution>>> s1.compare(s2, keep_shape=True) self other 0 NaN NaN 1 b a 2 NaN NaN 3 d b 4 NaN NaN
Keep all original rows and also all original values
This example is valid syntax, but we were not able to check execution>>> s1.compare(s2, keep_shape=True, keep_equal=True) self other 0 a a 1 b a 2 c c 3 d b 4 e eSee :
The following pages refer to to this document either explicitly or contain code examples using this.
pandas.core.frame.DataFrame.compare
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them