Skip to content

Commit 76e46f9

Browse files
jbrockmendelalanbato
authored andcommitted
Fix typo that causes several NaT methods to have incorrect docstrings (pandas-dev#17327)
1 parent 867c512 commit 76e46f9

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

doc/source/whatsnew/v0.21.0.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,3 +428,4 @@ Other
428428
- The ``Series`` constructor with no arguments would have an index like ``Index([], dtype='object')`` instead of ``RangeIndex(start=0, stop=0, step=1)``
429429
- Bug in ``.isin()`` in which checking membership in empty ``Series`` objects raised an error (:issue:`16991`)
430430
- Bug in :func:`unique` where checking a tuple of strings raised a ``TypeError`` (:issue:`17108`)
431+
- Several ``NaT`` method docstrings (e.g. :func:`NaT.ctime`) were incorrect (:issue:`17327`)

pandas/_libs/tslib.pyx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
# cython: profile=False
23

34
import warnings
@@ -3922,7 +3923,7 @@ for _method_name in _nat_methods:
39223923
def f(*args, **kwargs):
39233924
return NaT
39243925
f.__name__ = func_name
3925-
f.__doc__ = _get_docstring(_method_name)
3926+
f.__doc__ = _get_docstring(func_name)
39263927
return f
39273928

39283929
setattr(NaTType, _method_name, _make_nat_func(_method_name))
@@ -3934,7 +3935,7 @@ for _method_name in _nan_methods:
39343935
def f(*args, **kwargs):
39353936
return np.nan
39363937
f.__name__ = func_name
3937-
f.__doc__ = _get_docstring(_method_name)
3938+
f.__doc__ = _get_docstring(func_name)
39383939
return f
39393940

39403941
setattr(NaTType, _method_name, _make_nan_func(_method_name))
@@ -3952,7 +3953,7 @@ for _maybe_method_name in dir(NaTType):
39523953
def f(*args, **kwargs):
39533954
raise ValueError("NaTType does not support " + func_name)
39543955
f.__name__ = func_name
3955-
f.__doc__ = _get_docstring(_method_name)
3956+
f.__doc__ = _get_docstring(func_name)
39563957
return f
39573958

39583959
setattr(NaTType, _maybe_method_name,

pandas/tests/scalar/test_nat.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,3 +247,8 @@ def test_nat_arithmetic_index():
247247
tm.assert_index_equal(right + left, exp)
248248
tm.assert_index_equal(left - right, exp)
249249
tm.assert_index_equal(right - left, exp)
250+
251+
252+
def test_nat_pinned_docstrings():
253+
# GH17327
254+
assert NaT.ctime.__doc__ == datetime.ctime.__doc__

0 commit comments

Comments
 (0)