-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: pandas.to_datetime() does not respect exact format string with ISO8601 #49333
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
Changes from 21 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
45f82c3
initial format support
nikitaved e473adb
set exact=False default in objects_to_datetime
a6ea6d0
:label: typing
8fede1f
simplify
2e21e71
Merge remote-tracking branch 'upstream/main' into pr/nikitaved-qssumm…
afc4d96
Merge remote-tracking branch 'upstream/main' into pr/nikitaved/qssumm…
12721b0
replace macro with function
0531967
clean up
a571753
:memo: restore docstring
e814a2e
inline
19c34f8
set format default to None
70fb820
Merge remote-tracking branch 'upstream/main' into pr/nikitaved/qssumm…
eb50dfb
clean up
ac61ac5
Merge remote-tracking branch 'upstream/main' into pr/nikitaved/qssumm…
0dd7407
remove function, perform check inline
4d35ea7
Merge remote-tracking branch 'upstream/main' into pr/nikitaved/qssumm…
3acfdf6
only compare *format++ if format_len
f3060c9
clean up
7310e13
typing
b18ade7
Merge remote-tracking branch 'upstream/main' into pr/nikitaved/qssumm…
3ceb1ee
split out branches
bde5ef9
Merge remote-tracking branch 'upstream/main' into pr/nikitaved/qssumm…
080f018
use compare_format function
031e0e3
remove tmp variable
01e8bd1
Merge remote-tracking branch 'upstream/main' into pr/nikitaved/qssumm…
c1e6bc2
Add co-authors
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,8 @@ cdef extern from "src/datetime/np_datetime_strings.h": | |
int parse_iso_8601_datetime(const char *str, int len, int want_exc, | ||
npy_datetimestruct *out, | ||
NPY_DATETIMEUNIT *out_bestunit, | ||
int *out_local, int *out_tzoffset) | ||
int *out_local, int *out_tzoffset, | ||
const char *format, int format_len, int exact) | ||
|
||
|
||
# ---------------------------------------------------------------------- | ||
|
@@ -277,14 +278,25 @@ cdef inline int string_to_dts( | |
int* out_local, | ||
int* out_tzoffset, | ||
bint want_exc, | ||
format: str | None=None, | ||
bint exact=True, | ||
) except? -1: | ||
cdef: | ||
Py_ssize_t length | ||
const char* buf | ||
Py_ssize_t format_length | ||
const char* format_buf | ||
|
||
buf = get_c_string_buf_and_size(val, &length) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Orthogonal to this but if you want to work more with the C codebase I think we should just replace |
||
if format is None: | ||
format_buf = b'' | ||
format_length = 0 | ||
exact = False | ||
MarcoGorelli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
else: | ||
format_buf = get_c_string_buf_and_size(format, &format_length) | ||
return parse_iso_8601_datetime(buf, length, want_exc, | ||
dts, out_bestunit, out_local, out_tzoffset) | ||
dts, out_bestunit, out_local, out_tzoffset, | ||
format_buf, format_length, exact) | ||
|
||
|
||
cpdef ndarray astype_overflowsafe( | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parse_iso_8601_datetime
is now more than 500 non-comment lines, so I've turned off that check for nowThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separate to this but I would also be fine exploring another tool aside from cpplint. I haven't seen many other projects use this tool, particularly for C instead of C++. clang has a formating and static analyzer tool that would likely be more useful