-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
API/COMPAT: add pydatetime-style positional args to Timestamp constructor #12482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
0d6884b
5c34c04
6fad30b
9c1e2dc
a334eab
0ac786f
79d63d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -225,8 +225,12 @@ class Timestamp(_Timestamp): | |
for the entries that make up a DatetimeIndex, and other timeseries | ||
oriented data structures in pandas. | ||
|
||
Parameters | ||
---------- | ||
There are essentially three calling conventions for the constructor. The | ||
first, legacy form accepts four parameters. They can be passed by | ||
position or keyword. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add a versionadded tag here (0.18.2) |
||
|
||
Legacy Parameters | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't call these |
||
----------------- | ||
ts_input : datetime-like, str, int, float | ||
Value to be converted to Timestamp | ||
offset : str, DateOffset | ||
|
@@ -235,6 +239,20 @@ class Timestamp(_Timestamp): | |
Time zone for time which Timestamp will have. | ||
unit : string | ||
numpy unit used for conversion, if ts_input is int or float | ||
|
||
The other two forms copy the parameters from datetime.datetime. They can | ||
be passed by either position or keyword, but not both mixed together. | ||
|
||
datetime.datetime Parameters | ||
------------------------------ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. put a refernce to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the format for that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
be sure to put a blank line before and after (otherwise we get warnings) |
||
year : int | ||
month : int | ||
day : int | ||
hour : int [optional] | ||
minute : int [optional] | ||
second : int [optional] | ||
microsecond : int [optional] | ||
tzinfo : datetime.tzinfo [optional] | ||
""" | ||
|
||
@classmethod | ||
|
@@ -319,7 +337,7 @@ class Timestamp(_Timestamp): | |
return Timestamp(datetime(year, month, day, hour or 0, | ||
minute or 0, second or 0, microsecond or 0, tzinfo), | ||
tz=tzinfo) | ||
if is_integer_object(offset): | ||
elif is_integer_object(offset): | ||
# User passed positional arguments: | ||
# Timestamp(year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]]) | ||
return Timestamp(datetime(ts_input, offset, tz, unit or 0, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this also seems superfluous (the
.to_pydatetime()
check)