Skip to content
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

PR09 batch 4 #29466

Merged
merged 17 commits into from
Nov 8, 2019
Merged
Prev Previous commit
Next Next commit
PR09 in pandas.to_datetime
  • Loading branch information
HughKelley committed Nov 7, 2019
commit 3763e462af8ab0c2f2361ec19acdb2193e73da5e
32 changes: 16 additions & 16 deletions pandas/core/tools/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,14 +577,13 @@ def to_datetime(

Parameters
----------
arg : int, float, str, datetime, list, tuple, 1-d array, Series
or DataFrame/dict-like

arg : int, float, str, datetime, list, tuple, 1-d array, Series DataFrame/dict-like
The object to convert to a datetime.
errors : {'ignore', 'raise', 'coerce'}, default 'raise'

- If 'raise', then invalid parsing will raise an exception
- If 'coerce', then invalid parsing will be set as NaT
- If 'ignore', then invalid parsing will return the input
Behaves as:
Copy link
Member

Choose a reason for hiding this comment

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

Was this required to get validation to work?

Copy link
Member

Choose a reason for hiding this comment

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

You can remove all this. The new version of the script doesn't fail if the description starts with a list. And we'll move to the new version of the script soon.

- If 'raise', then invalid parsing will raise an exception.
- If 'coerce', then invalid parsing will be set as NaT.
- If 'ignore', then invalid parsing will return the input.
dayfirst : bool, default False
Specify a date parse order if `arg` is str or its list-likes.
If True, parses dates with the day first, eg 10/11/12 is parsed as
Expand All @@ -605,7 +604,7 @@ def to_datetime(
Return UTC DatetimeIndex if True (converting any tz-aware
datetime.datetime objects as well).
box : bool, default True

Behaves as:
- If True returns a DatetimeIndex or Index-like object
- If False returns ndarray of values.

Expand All @@ -615,17 +614,17 @@ def to_datetime(
respectively.

format : str, default None
strftime to parse time, eg "%d/%m/%Y", note that "%f" will parse
The strftime to parse time, eg "%d/%m/%Y", note that "%f" will parse
all the way up to nanoseconds.
See strftime documentation for more information on choices:
https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior
https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior.
exact : bool, True by default

Behaves as:
- If True, require an exact format match.
- If False, allow the format to match anywhere in the target string.

unit : str, default 'ns'
unit of the arg (D,s,ms,us,ns) denote the unit, which is an
The unit of the arg (D,s,ms,us,ns) denote the unit, which is an
integer or float number. This will be based off the origin.
Example, with unit='ms' and origin='unix' (the default), this
would calculate the number of milliseconds to the unix epoch start.
Expand All @@ -652,11 +651,12 @@ def to_datetime(
.. versionadded:: 0.23.0

.. versionchanged:: 0.25.0
- changed default value from False to True
- changed default value from False to True.

Returns
-------
ret : datetime if parsing succeeded.
datetime
If parsing succeeded.
Return type depends on input:

- list-like: DatetimeIndex
Expand Down Expand Up @@ -712,10 +712,10 @@ def to_datetime(
4 3/12/2000
dtype: object

>>> %timeit pd.to_datetime(s,infer_datetime_format=True) # doctest: +SKIP
>>> %timeit pd.to_datetime(s, infer_datetime_format=True) # doctest: +SKIP
100 loops, best of 3: 10.4 ms per loop

>>> %timeit pd.to_datetime(s,infer_datetime_format=False) # doctest: +SKIP
>>> %timeit pd.to_datetime(s, infer_datetime_format=False) # doctest: +SKIP
1 loop, best of 3: 471 ms per loop

Using a unix epoch time
Expand Down