Closed flownt closed 1 week ago
Hi, I noticed this issue and I'd like to help triage and potentially fix it. Is it okay if I proceed with investigating this bug? Thanks!
Sure! From the outside I would guess the series is processed in batches and accidentally the numeric index into the batch is returned instead of the index of the series element. If you play with the the length of the valid list you'll notice it jumping around but rarely being correct.
Thank you for the insight! I will look into this and investigate further, after I will update here. Appreciate the guidance!
Thanks for the report. It appears to me that duplicates are first removed from the values. It seems easiest to just remove the index from the error message. Further investigations and PRs to fix are welcome!
Take
I'd like to work on this, thanks
Thanks for the report. It appears to me that duplicates are first removed from the values. It seems easiest to just remove the index from the error message. Further investigations and PRs to fix are welcome!
I took some time to look into the code and this seems correct.
The error message comes from:
array_strptime in pandas/pandas/_libs/tslibs/strptime.pyx
which appears to be called indirectly from pandas/pandas/core/tools/datetimes.py:1015
The cause appears to be as @rhshadrach said: the series is first deduplicated by _maybe_cache and only then the date-parsing is applied.
The branches at 1023 and 1029 appear to also be affected.
As a pandas.Series has an index it seems most consistent to me to report the item causing the error by the index.
Thanks for the report. It appears to me that duplicates are first removed from the values. It seems easiest to just remove the index from the error message. Further investigations and PRs to fix are welcome!
Just reproduced the issue and looks like this is the cause. I would like to contribute towards the fix.
take
Pandas version checks
[X] I have checked that this issue has not already been reported.
[X] I have confirmed this bug exists on the latest version of pandas.
[ ] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
As you can see a ValueError is raised. That is fine.
The description says it happens for item at postition 1, however, which is not correct. It happens for item at position 45000.
Expected Behavior
The correct position would be reported to the user. I'd like to do S[] and be able to see why it raised valueError.
Installed Versions