Skip to content

Commit 9c1e2dc

Browse files
review fixes: versionadded, issue links, repr tests, legacy
1 parent 6fad30b commit 9c1e2dc

File tree

3 files changed

+23
-33
lines changed

3 files changed

+23
-33
lines changed

doc/source/whatsnew/v0.18.2.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Other enhancements
3838
idx = pd.Index(["a1a2", "b1", "c1"])
3939
idx.str.extractall("[ab](?P<digit>\d)")
4040

41-
- ``Timestamp``s can now accept positional parameters like :func:`datetime.datetime`:
41+
- ``Timestamp``s can now accept positional and keyword parameters like :func:`datetime.datetime` (:issue:`10758`, :issue:`11630`)
4242

4343
.. ipython:: python
4444

pandas/tseries/tests/test_tslib.py

+15-28
Original file line numberDiff line numberDiff line change
@@ -193,16 +193,14 @@ def test_constructor_positional(self):
193193
with tm.assertRaises(ValueError):
194194
Timestamp(2000, 1, 32)
195195

196-
ts = Timestamp(2000, 1, 2)
197-
198-
actual = ts.to_pydatetime()
199-
expected = datetime.datetime(2000, 1, 2)
200-
self.assertEqual(actual, expected)
201-
self.assertEqual(type(actual), type(expected))
196+
# GH 11630
197+
self.assertEqual(
198+
repr(Timestamp(2015, 11, 12)),
199+
repr(Timestamp('20151112')))
202200

203-
pos_args = [2000, 1, 2, 3, 4, 5, 999999]
204-
self.assertEqual(Timestamp(*pos_args).to_pydatetime(),
205-
datetime.datetime(*pos_args))
201+
self.assertEqual(
202+
repr(Timestamp(2015, 11, 12, 1, 2, 3, 999999)),
203+
repr(Timestamp('2015-11-12 01:02:03.999999')))
206204

207205
def test_constructor_keyword(self):
208206
# GH 10758
@@ -217,25 +215,14 @@ def test_constructor_keyword(self):
217215
with tm.assertRaises(ValueError):
218216
Timestamp(year=2000, month=1, day=32)
219217

220-
ts = Timestamp(year=2000, month=1, day=2)
221-
222-
actual = ts.to_pydatetime()
223-
expected = datetime.datetime(year=2000, month=1, day=2)
224-
self.assertEqual(actual, expected)
225-
self.assertEqual(type(actual), type(expected))
226-
227-
pos_args = [2000, 1, 2, 3, 4, 5, 999999]
228-
kw_args = {
229-
'year': 2000,
230-
'month': 1,
231-
'day': 2,
232-
'hour': 3,
233-
'minute': 4,
234-
'second': 5,
235-
'microsecond': 999999,
236-
}
237-
self.assertEqual(Timestamp(**kw_args).to_pydatetime(),
238-
datetime.datetime(**kw_args))
218+
self.assertEqual(
219+
repr(Timestamp(year=2015, month=11, day=12)),
220+
repr(Timestamp('20151112')))
221+
222+
self.assertEqual(
223+
repr(Timestamp(year=2015, month=11, day=12,
224+
hour=1, minute=2, second=3, microsecond=999999)),
225+
repr(Timestamp('2015-11-12 01:02:03.999999')))
239226

240227
def test_conversion(self):
241228
# GH 9255

pandas/tslib.pyx

+7-4
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,10 @@ class Timestamp(_Timestamp):
226226
oriented data structures in pandas.
227227
228228
There are essentially three calling conventions for the constructor. The
229-
first, legacy form accepts four parameters. They can be passed by
230-
position or keyword.
229+
primary form accepts four parameters. They can be passed by position or
230+
keyword.
231231
232-
Legacy Parameters
232+
Parameters
233233
-----------------
234234
ts_input : datetime-like, str, int, float
235235
Value to be converted to Timestamp
@@ -243,8 +243,11 @@ class Timestamp(_Timestamp):
243243
The other two forms copy the parameters from datetime.datetime. They can
244244
be passed by either position or keyword, but not both mixed together.
245245
246-
datetime.datetime Parameters
246+
:func:`datetime.datetime` Parameters
247247
------------------------------
248+
249+
.. versionadded:: 0.18.2
250+
248251
year : int
249252
month : int
250253
day : int

0 commit comments

Comments
 (0)