When we have exact same columns in source and target dataframes and distinct number of rows then we are seeing below exception which according to me is misleading.
"ValueError: Can only compare identically-labeled DataFrame objects"
CODE :
```import pandas as pd
define DataFrames
df1 = pd.DataFrame({'points': [25, 12, 15, 14], 'assists': [5, 7, 13, 12]})
df2 = pd.DataFrame({'points': [25, 12, 15], 'assists': [5, 7, 13]})
print(df1)
points assists 0 25 5 1 12 7 2 15 13 3 14 12
print(df2)
points assists 0 25 5 1 12 7 2 15 13
Compare both dataframes
df1.compare(df2)
+++++++++++++++++++++++++++++++++ERROR+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Traceback (most recent call last):
File "", line 1, in
**Comment From: rhshadrach**
Thanks for the report; labels can refer to either column labels or row labels.
**Comment From: phofl**
Agreed, the exception is not misleading but could be clearer in the sense that it includes index/columns or both
**Comment From: abhid001**
@rhshadrach Thanks for the confirmation but it would be great if it gives clear idea about the error instead a generic one. Like @phofl said it should include something specific to either column or row labels.
Also i was looking if i can make that enhancement and submit a review request for the same.
**Comment From: MarcoGorelli**
OK, so how about changing
Can only compare identically-labeled DataFrame objects
to
Can only compare identically-labeled (both index and columns) DataFrame objects ``` ?
This'd need changing in a few places, as well as in tests. But agree that it'd be nice to clarify
Comment From: abhid001
take