pybaseball icon indicating copy to clipboard operation
pybaseball copied to clipboard

Fix datetime deprecation

Open hsum opened this issue 9 months ago • 2 comments

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)

hsum avatar Mar 31 '25 05:03 hsum

This fixes issue #467 by removing the warning.

hsum avatar Mar 31 '25 15:03 hsum

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.

agene0001 avatar Oct 24 '25 18:10 agene0001