Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pandas df with datetime.date cols returns false differences if ignore_case=True #327

Open
sundeep-longledge opened this issue Aug 20, 2024 · 1 comment

Comments

@sundeep-longledge
Copy link

When ignore_case=True, identical values with type datetime.date will be reported as unequal.
This happens because in core.py/columns_equal() the attempt to call str.upper() on the col for case insensitive-comparison will throw an exception. The try/except returns false for any caught exception.

import pandas as pd
import datacompy
import datetime

df1 = pd.DataFrame([{'date_field':datetime.date(2024,5,8)}])
df2=df1.copy()

print("incorrectly reports unequal")                            
results = datacompy.Compare(df1=df1,df2=df2,on_index=True, ignore_case=True)
print(results.report())

results = datacompy.Compare(df1=df1,df2=df2,on_index=True, ignore_case=False)
print("Works correctly")                            
print(results.report())
@fdosani
Copy link
Member

fdosani commented Aug 20, 2024

So it seems to be an issue of datetime.date vs datetime.datetime. date returns an O (object) vs datetime which returns a type of M. We could just convert all objects to "strings" and then compare, but I'm sure that will break something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants