@@ -105,11 +105,17 @@ def _convert_and_box_cache(arg, cache_array, box, errors, name=None):
105
105
106
106
def to_datetime (arg , errors = 'raise' , dayfirst = False , yearfirst = False ,
107
107
utc = None , box = True , format = None , exact = True ,
108
- unit = None , infer_datetime_format = False , require_iso8601 = False ,
109
- origin = 'unix' , cache = False ):
108
+ unit = None , infer_datetime_format = False , origin = 'unix' ,
109
+ cache = False , _require_iso8601 = False ):
110
110
"""
111
111
Convert argument to datetime.
112
112
113
+ Passing _require_iso8601=True will only parse datetime strings similar to
114
+ `ISO8601 <https://en.wikipedia.org/wiki/ISO_8601>`_ and treat others as
115
+ non-parseable dates.
116
+
117
+ .. versionadded:: 0.23.0
118
+
113
119
Parameters
114
120
----------
115
121
arg : integer, float, string, datetime, list, tuple, 1-d array, Series
@@ -167,10 +173,6 @@ def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False,
167
173
datetime strings, and if it can be inferred, switch to a faster
168
174
method of parsing them. In some cases this can increase the parsing
169
175
speed by ~5-10x.
170
- require_iso8601 : boolean, default False
171
- If True, only try to infer ISO8601-compliant datetime strings.
172
-
173
- .. versionadded:: 0.23.0
174
176
origin : scalar, default is 'unix'
175
177
Define the reference date. The numeric values would be parsed as number
176
178
of units (defined by `unit`) since this reference date.
@@ -250,24 +252,6 @@ def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False,
250
252
>>> %timeit pd.to_datetime(s,infer_datetime_format=False)
251
253
1 loop, best of 3: 471 ms per loop
252
254
253
- Passing require_iso8601=True will only parse datetime strings compliant to
254
- `ISO8601 <https://en.wikipedia.org/wiki/ISO_8601>`_ and treat others as
255
- non-parseable dates.
256
-
257
- >>> s = pd.Series(['M1809', 'M1701', pd.Timestamp('20130101')])
258
-
259
- >>> pd.to_datetime(s, require_iso8601=False, errors='raise')
260
- 0 1809-01-01
261
- 1 1701-01-01
262
- 2 2013-01-01
263
- dtype: datetime64[ns]
264
-
265
- >>> pd.to_datetime(s, require_iso8601=True, errors='coerce')
266
- 0 NaT
267
- 1 NaT
268
- 2 2013-01-01
269
- dtype: datetime64[ns]
270
-
271
255
Using a unix epoch time
272
256
273
257
>>> pd.to_datetime(1490195805, unit='s')
@@ -296,7 +280,7 @@ def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False,
296
280
tz = 'utc' if utc else None
297
281
298
282
def _convert_listlike (arg , box , format , name = None , tz = tz ,
299
- require_iso8601 = require_iso8601 ):
283
+ require_iso8601 = _require_iso8601 ):
300
284
301
285
if isinstance (arg , (list , tuple )):
302
286
arg = np .array (arg , dtype = 'O' )
0 commit comments