Skip to content

Commit 0d676a3

Browse files
jbrockmendeljreback
authored andcommitted
Fix typo that causes several NaT methods to have incorrect docstrings (#17327)
1 parent 0618f99 commit 0d676a3

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

doc/source/whatsnew/v0.21.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -425,3 +425,4 @@ Categorical
425425
Other
426426
^^^^^
427427
- Bug in :func:`eval` where the ``inplace`` parameter was being incorrectly handled (:issue:`16732`)
428+
- Several ``NaT`` method docstrings (e.g. :func:`NaT.ctime`) were incorrect (:issue:`17327`)

pandas/_libs/tslib.pyx

+4-3
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

+5
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)