Skip to content

BUG: fixed OutOfBoundsDatetime exception when errors=coerce #45319 #47794

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

Merged
merged 10 commits into from
Aug 15, 2022

Conversation

srotondo
Copy link
Contributor

Copy link
Member

@phofl phofl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this not swallow the errors when errors!="corece"?

@srotondo
Copy link
Contributor Author

This function that this change is in doesn't care about the error variable, shown by the fact that there is no argument for the errors in the code. This function will always return NaT, and the raise and coerce cases are dealt with later in the program.

Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would need tests

@mroeschke mroeschke added Datetime Datetime data dtype Error Reporting Incorrect or improved errors from pandas labels Jul 22, 2022
"series_length",
[40, start_caching_at, (start_caching_at + 1), (start_caching_at + 5)],
)
def test_to_datetime_cache_coerce_50_lines(series_length):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def test_to_datetime_cache_coerce_50_lines(series_length):
def test_to_datetime_cache_coerce_50_lines_outofbounds(series_length):

Also could you test the ignore and raise options as well?

try:
cache_array = Series(cache_dates, index=unique_dates)
except OutOfBoundsDatetime:
pass
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense just to return cache_array here since the cache_array cannot be used due to the out of bounds date?

@mroeschke mroeschke added this to the 1.5 milestone Aug 15, 2022
@mroeschke mroeschke merged commit 60a2d56 into pandas-dev:main Aug 15, 2022
@mroeschke
Copy link
Member

Thanks @srotondo

YYYasin19 pushed a commit to YYYasin19/pandas that referenced this pull request Aug 23, 2022
…v#45319 (pandas-dev#47794)

* BUG: fixed OutOfBoundsDatetime exception when errors=coerce pandas-dev#45319

* BUG: Added test and release note pandas-dev#45319

* BUG: Restructured test parameters pandas-dev#45319

* BUG: Restructured test pandas-dev#45319

* BUG: Restructured parameters for test pandas-dev#45319

* BUG: Renamed test and added raise and ignore cases pandas-dev#45319

* BUG: Changed exception case pandas-dev#45319

Co-authored-by: Steven Rotondo <[email protected]>
noatamir pushed a commit to noatamir/pandas that referenced this pull request Nov 9, 2022
…v#45319 (pandas-dev#47794)

* BUG: fixed OutOfBoundsDatetime exception when errors=coerce pandas-dev#45319

* BUG: Added test and release note pandas-dev#45319

* BUG: Restructured test parameters pandas-dev#45319

* BUG: Restructured test pandas-dev#45319

* BUG: Restructured parameters for test pandas-dev#45319

* BUG: Renamed test and added raise and ignore cases pandas-dev#45319

* BUG: Changed exception case pandas-dev#45319

Co-authored-by: Steven Rotondo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Error Reporting Incorrect or improved errors from pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Calling to_datetime With errrors="coerce" Still Raises After 50 Rows
4 participants