Skip to content

Commit da53aac

Browse files
committed
revised
1 parent 2fece99 commit da53aac

File tree

6 files changed

+20
-26
lines changed

6 files changed

+20
-26
lines changed

doc/source/whatsnew/v0.20.0.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,9 +537,9 @@ Deprecations
537537
- ``Series/DataFrame/Panel.consolidate()`` been deprecated as a public method. (:issue:`15483`)
538538
- ``FrozenList`` addition (new object and inplace) have been deprecated in favor of the ``.union()`` method. (:issue: `15475`)
539539
- The following top-level pandas functions have been deprecated and will be removed in a future version (:issue:`13790`)
540-
* ``pd.now()``, replaced by a direct import from ``pandas.tseries.period``
541-
* ``pd.Term``, replaced by a direct import from ``pandas.io.pytables``
542-
* ``pd.Expr``, replaced by a direct import from ``pandas.computation.expr``
540+
* ``pd.pnow()``, replaced by ``Period.now()``
541+
* ``pd.Term``, not applicable to the user
542+
* ``pd.Expr``, not applicable to the user
543543
* ``pd.match()``, replaced by a direct import from ``pandas.core.algorithms``
544544
* ``pd.groupby()``, replaced by using the ``.groupby()`` method directly on a ``Series/DataFrame``
545545

pandas/computation/api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
def Expr(*args, **kwargs):
88
import warnings
99

10-
warnings.warn("pd.Expr is deprecated. Please import from pandas.computation.expr",
10+
warnings.warn("pd.Expr is deprecated as it is not "
11+
"applicable to user code",
1112
FutureWarning, stacklevel=2)
1213
from pandas.computation.expr import Expr
1314
return Expr(*args, **kwargs)

pandas/io/api.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
def Term(*args, **kwargs):
2323
import warnings
2424

25-
warnings.warn("pd.Term is deprecated. Please import from pandas.io.pytables",
25+
warnings.warn("pd.Term is deprecated as it is not "
26+
"applicable to user code. Instead use in-line "
27+
"string expressions in for searching HDFStore",
2628
FutureWarning, stacklevel=2)
2729
from pandas.io.pytables import Term
2830
return Term(*args, **kwargs)

pandas/tests/scalar/test_period.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -864,17 +864,11 @@ def test_properties_nat(self):
864864
self.assertTrue(np.isnan(getattr(t_nat, f)))
865865

866866
def test_pnow(self):
867-
dt = datetime.now()
868867

869-
val = period.pnow('D')
870-
exp = Period(dt, freq='D')
871-
self.assertEqual(val, exp)
872-
873-
val2 = period.pnow('2D')
874-
exp2 = Period(dt, freq='2D')
875-
self.assertEqual(val2, exp2)
876-
self.assertEqual(val.ordinal, val2.ordinal)
877-
self.assertEqual(val.ordinal, exp2.ordinal)
868+
# deprecation, xref #13790
869+
with tm.assert_produces_warning(FutureWarning,
870+
check_stacklevel=False):
871+
period.pnow('D')
878872

879873
def test_constructor_corner(self):
880874
expected = Period('2007-01', freq='2M')

pandas/tseries/api.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,8 @@
77
from pandas.tseries.index import DatetimeIndex, date_range, bdate_range
88
from pandas.tseries.frequencies import infer_freq
99
from pandas.tseries.tdi import Timedelta, TimedeltaIndex, timedelta_range
10-
from pandas.tseries.period import Period, PeriodIndex, period_range
10+
from pandas.tseries.period import Period, PeriodIndex, period_range, pnow
1111
from pandas.tseries.resample import TimeGrouper
1212
from pandas.tseries.timedeltas import to_timedelta
1313
from pandas.lib import NaT
1414
import pandas.tseries.offsets as offsets
15-
16-
# deprecation, xref #13790
17-
def pnow(freq=None):
18-
import warnings
19-
20-
warnings.warn("pd.pnow() is deprecated. Please use pandas.tseries.period.pnow()",
21-
FutureWarning, stacklevel=2)
22-
from pandas.tseries.period import pnow
23-
return pnow(freq=freq)

pandas/tseries/period.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,13 @@ def _make_field_arrays(*fields):
11441144

11451145

11461146
def pnow(freq=None):
1147-
return Period(datetime.now(), freq=freq)
1147+
# deprecation, xref #13790
1148+
import warnings
1149+
1150+
warnings.warn("pd.pnow() and pandas.tseries.period.pnow() "
1151+
"are deprecated. Please use Period.now()",
1152+
FutureWarning, stacklevel=2)
1153+
return Period.now(freq=freq)
11481154

11491155

11501156
def period_range(start=None, end=None, periods=None, freq='D', name=None):

0 commit comments

Comments
 (0)