Skip to content

BUG: pandas.to_datetime() does not respect exact format string with ISO8601 #49232

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

Closed
wants to merge 7 commits into from

Conversation

MarcoGorelli
Copy link
Member

I'm working on cleaning up / deduplicating the code

Comment on lines 517 to 518
char inferred_format[100]
int inferred_format_len
Copy link
Member Author

@MarcoGorelli MarcoGorelli Oct 21, 2022

Choose a reason for hiding this comment

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

hi @WillAyd - I don't have much experience with C, what would be a better way to do this?

What I'm trying to do is:

  • make a character array inferred_format in which to record the format which is guessed within parse_iso_8601_datetime
  • record the length of the inferred format into inferred_format_len

and then compare format with inferred_format[:inferred_format_len]

I'll try to figure this out, but I'm aware that char inferred_format[1000] is not the solution, just seeing if I can get something working first

EDIT: looks like strcat from string.h could work for this

EDIT2: passing a string to parse_iso_8601_datetime that gets written to is proving too hard, I think I'll just try a simpler approach of passing format to parse_iso_8601_datetime, and checking that the inferred format matches it as it gets parsed

@mroeschke mroeschke added the Datetime Datetime data dtype label Oct 21, 2022
@MarcoGorelli
Copy link
Member Author

closing, will take this forward in #49333, will add some commits there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: pandas.to_datetime() does not respect exact format string with ISO8601
2 participants