pybaseball
pybaseball copied to clipboard
Fix datetime deprecation
Fix pandas to_datetime deprecation warning
This PR removes a FutureWarning in pybaseball/datahelpers/postprocessing.py related to the use of errors='ignore' in pd.to_datetime, which is being deprecated.
Changes:
- Wrapped call to df.to_datetime in a function and in a try: except: block
- Maintained the same results while removing the warning
Testing:
- Confirmed the warning no longer appears
- Verified that date parsing still works correctly with both valid and invalid dates
Original warning:
pybaseball/datahelpers/postprocessing.py:59: FutureWarning: errors='ignore' is deprecated and will raise in a future version. Use to_datetime without passing `errors` and catch exceptions explicitly instead
data_copy[column] = data_copy[column].apply(pd.to_datetime, errors='ignore', format=date_format)
This fixes issue #467 by removing the warning.
Hi I was wondering if this pr will be merged soon as I get the errors in my implementation of pybaseball still? It doesn't seem like that hard of a fix but I get it if for some reason it might be failing some tests.