Skip to content

Conversation

@hsum
Copy link
Contributor

@hsum hsum commented Mar 31, 2025

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
Copy link
Contributor Author

hsum commented Mar 31, 2025

This fixes issue #467 by removing the warning.

@agene0001
Copy link

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.

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

Successfully merging this pull request may close these issues.

2 participants