Skip to content

Commit 84f0526

Browse files
committed
DOC: more pd.to_datetime examples
1 parent 0843911 commit 84f0526

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

doc/source/api.rst

+1
Original file line numberDiff line numberDiff line change
@@ -1781,6 +1781,7 @@ Upsampling
17811781
Resampler.pad
17821782
Resampler.fillna
17831783
Resampler.asfreq
1784+
Resampler.interpolate
17841785

17851786
Computations / Descriptive Stats
17861787
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

pandas/core/generic.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -3446,8 +3446,6 @@ def replace(self, to_replace=None, value=None, inplace=False, limit=None,
34463446
return self._constructor(new_data).__finalize__(self)
34473447

34483448
_shared_docs['interpolate'] = """
3449-
Interpolate values according to different methods.
3450-
34513449
Please note that only ``method='linear'`` is supported for
34523450
DataFrames/Series with a MultiIndex.
34533451
@@ -3523,6 +3521,10 @@ def replace(self, to_replace=None, value=None, inplace=False, limit=None,
35233521
@Appender(_shared_docs['interpolate'] % _shared_doc_kwargs)
35243522
def interpolate(self, method='linear', axis=0, limit=None, inplace=False,
35253523
limit_direction='forward', downcast=None, **kwargs):
3524+
"""
3525+
Interpolate values according to different methods.
3526+
"""
3527+
35263528
if self.ndim > 2:
35273529
raise NotImplementedError("Interpolate has not been implemented "
35283530
"on Panel and Panel 4D objects.")

pandas/tseries/resample.py

+2
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,8 @@ def fillna(self, method, limit=None):
462462
def interpolate(self, method='linear', axis=0, limit=None, inplace=False,
463463
limit_direction='forward', downcast=None, **kwargs):
464464
"""
465+
Interpolate values according to different methods.
466+
465467
.. versionadded:: 0.18.1
466468
"""
467469
result = self._upsample(None)

pandas/tseries/tools.py

+22-1
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,33 @@ def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False,
257257
1 2016-03-05
258258
dtype: datetime64[ns]
259259
260-
Date that does not meet timestamp limitations:
260+
If a date that does not meet timestamp limitations, passing errors='coerce'
261+
will force to NaT. Furthermore this will force non-dates to NaT as well.
261262
262263
>>> pd.to_datetime('13000101', format='%Y%m%d')
263264
datetime.datetime(1300, 1, 1, 0, 0)
264265
>>> pd.to_datetime('13000101', format='%Y%m%d', errors='coerce')
265266
NaT
267+
268+
Passing infer_datetime_format=True can often-times speedup a parsing
269+
if its not an ISO8601 format exactly, but in a regular format.
270+
271+
>>> s = pd.Series(['3/11/2000', '3/12/2000', '3/13/2000']*1000)
272+
273+
>>> s.head()
274+
0 3/11/2000
275+
1 3/12/2000
276+
2 3/13/2000
277+
3 3/11/2000
278+
4 3/12/2000
279+
dtype: object
280+
281+
>>> %timeit pd.to_datetime(s,infer_datetime_format=True)
282+
100 loops, best of 3: 10.4 ms per loop
283+
284+
>>> %timeit pd.to_datetime(s,infer_datetime_format=False)
285+
1 loop, best of 3: 471 ms per loop
286+
266287
"""
267288
return _to_datetime(arg, errors=errors, dayfirst=dayfirst,
268289
yearfirst=yearfirst,

0 commit comments

Comments
 (0)