-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Improved docs for infer_datetime_format #12606
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
Conversation
@@ -132,8 +132,10 @@ class ParserWarning(Warning): | |||
|
|||
Note: A fast-path exists for iso8601-formatted dates. | |||
infer_datetime_format : boolean, default False | |||
If True and parse_dates is enabled for a column, attempt to infer | |||
the datetime format to speed up the processing | |||
If parse_dates is enabled and this flag is set, pandas will attempt to |
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.
add if True
pls add to doc-string of |
Thanks - I think I've sorted all of those now. |
maybe show an example where this helps (in Examples) mainly for pd.to_datetime |
Infer the format from the first entry | ||
|
||
>>> pd.to_datetime(df.month + '/' + df.day + '/' + df.year, | ||
infer_datetime_format=True) |
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.
this is not valid code (as df.month
are integers), do something like:
s = df.month.astype(str) + '/' + df.day.astype(str) + '/' + df.year.astype(str)
then infer on that
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.
I assumed that the df = df.astype(str)
from the example above would still have applied.
Should each example be entirely separate?
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.
ahh I see that. ok no, that is fine then (maybe rename df
-> dfs
or something (on the .astype(str)
line)
thanks! |
Fixes #12152