-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
DOC: document subclasses in API docs with selection of specific methods/attributes #18202
Changes from 17 commits
500ab71
257fc8a
d59c0b5
cb57504
5e4cf6d
346a73b
b5902ff
af1e866
874aefe
32c2816
38673bd
e30335e
38efdcb
5e8bcbe
8695727
4476a5f
a5005e1
aa92592
8841035
1527cdb
7ca3434
5a0e10e
c8504d1
f7ed015
094f6f6
1c2160f
6e99be2
3bd03db
ba257cc
169e833
f846713
141107a
3a224be
34834fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -288,6 +288,8 @@ class Timestamp(_Timestamp): | |
@classmethod | ||
def fromordinal(cls, ordinal, freq=None, tz=None, offset=None): | ||
""" | ||
Timestamp.fromordinal(ordina, freq=None, tz=None, offset=None) | ||
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. typo ordina-->ordinal |
||
|
||
passed an ordinal, translate and convert to a ts | ||
note: by definition there cannot be any tz info on the ordinal itself | ||
|
||
|
@@ -308,8 +310,10 @@ class Timestamp(_Timestamp): | |
@classmethod | ||
def now(cls, tz=None): | ||
""" | ||
Return the current time in the local timezone. Equivalent | ||
to datetime.now([tz]) | ||
Timestamp.now(tz=None) | ||
|
||
Returns new Timestamp object representing current time local to | ||
tz. | ||
|
||
Parameters | ||
---------- | ||
|
@@ -323,6 +327,8 @@ class Timestamp(_Timestamp): | |
@classmethod | ||
def today(cls, tz=None): | ||
""" | ||
Timestamp.today(cls, tz=None) | ||
|
||
Return the current time in the local timezone. This differs | ||
from datetime.today() in that it can be localized to a | ||
passed timezone. | ||
|
@@ -336,18 +342,38 @@ class Timestamp(_Timestamp): | |
|
||
@classmethod | ||
def utcnow(cls): | ||
""" | ||
Timestamp.utcnow() | ||
|
||
Return a new Timestamp representing UTC day and time. | ||
""" | ||
return cls.now('UTC') | ||
|
||
@classmethod | ||
def utcfromtimestamp(cls, ts): | ||
""" | ||
Timestamp.utcfromtimestamp(ts) | ||
|
||
Construct a naive UTC datetime from a POSIX timestamp. | ||
""" | ||
return cls(datetime.utcfromtimestamp(ts)) | ||
|
||
@classmethod | ||
def fromtimestamp(cls, ts): | ||
""" | ||
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. sp? |
||
Timestamp.fromtimestamp(ts) | ||
|
||
timestamp[, tz] -> tz's local time from POSIX timestamp. | ||
""" | ||
return cls(datetime.fromtimestamp(ts)) | ||
|
||
@classmethod | ||
def combine(cls, date, time): | ||
""" | ||
Timsetamp.combine(date, time) | ||
|
||
date, time -> datetime with same date and time fields | ||
""" | ||
return cls(datetime.combine(date, time)) | ||
|
||
def __new__(cls, object ts_input=_no_input, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -336,16 +336,39 @@ class NaTType(_NaT): | |
tzname = _make_error_func('tzname', datetime) | ||
utcoffset = _make_error_func('utcoffset', datetime) | ||
|
||
# Timestamp has empty docstring for some methods. | ||
utcfromtimestamp = _make_error_func('utcfromtimestamp', None) | ||
fromtimestamp = _make_error_func('fromtimestamp', None) | ||
combine = _make_error_func('combine', None) | ||
utcnow = _make_error_func('utcnow', None) | ||
|
||
# ---------------------------------------------------------------------- | ||
# The remaining methods have docstrings copy/pasted from the analogous | ||
# Timestamp methods. | ||
|
||
utcfromtimestamp = _make_error_func('utcfromtimestamp', | ||
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. @jbrockmendel FYI I think you have a todo about this |
||
""" | ||
Timestamp.utcfromtimestamp(ts) | ||
|
||
Construct a naive UTC datetime from a POSIX timestamp. | ||
""" | ||
) | ||
fromtimestamp = _make_error_func('fromtimestamp', | ||
""" | ||
Timestamp.fromtimestamp(ts) | ||
|
||
timestamp[, tz] -> tz's local time from POSIX timestamp. | ||
""" | ||
) | ||
combine = _make_error_func('combine', | ||
""" | ||
Timsetamp.combine(date, time) | ||
|
||
date, time -> datetime with same date and time fields | ||
""" | ||
) | ||
utcnow = _make_error_func('utcnow', | ||
""" | ||
Timestamp.utcnow() | ||
|
||
Return a new Timestamp representing UTC day and time. | ||
""" | ||
) | ||
|
||
timestamp = _make_error_func('timestamp', # noqa:E128 | ||
"""Return POSIX timestamp as float.""") | ||
|
||
|
@@ -372,6 +395,8 @@ class NaTType(_NaT): | |
""") | ||
fromordinal = _make_error_func('fromordinal', # noqa:E128 | ||
""" | ||
Timestamp.fromordinal(ordina, freq=None, tz=None, offset=None) | ||
|
||
passed an ordinal, translate and convert to a ts | ||
note: by definition there cannot be any tz info on the ordinal itself | ||
|
||
|
@@ -397,8 +422,10 @@ class NaTType(_NaT): | |
|
||
now = _make_nat_func('now', # noqa:E128 | ||
""" | ||
Return the current time in the local timezone. Equivalent | ||
to datetime.now([tz]) | ||
Timestamp.now(tz=None) | ||
|
||
Returns new Timestamp object representing current time local to | ||
tz. | ||
|
||
Parameters | ||
---------- | ||
|
@@ -407,6 +434,8 @@ class NaTType(_NaT): | |
""") | ||
today = _make_nat_func('today', # noqa:E128 | ||
""" | ||
Timestamp.today(cls, tz=None) | ||
|
||
Return the current time in the local timezone. This differs | ||
from datetime.today() in that it can be localized to a | ||
passed timezone. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,6 +120,15 @@ class CategoricalDtype(ExtensionDtype): | |
Must be unique, and must not contain any nulls. | ||
ordered : bool, default False | ||
|
||
Attributes | ||
---------- | ||
categories | ||
ordered | ||
|
||
Methods | ||
------- | ||
None | ||
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. Is the problem that if you don't include this 'None', that it then automatically generated the 'Methods' section and thus included too much? 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. Yes, I'm not sure how best to avoid that. This is where class-level |
||
|
||
Notes | ||
----- | ||
This class is useful for specifying the type of a ``Categorical`` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,25 @@ class CategoricalIndex(Index, accessor.PandasDelegate): | |
See Also | ||
-------- | ||
Categorical, Index | ||
|
||
Methods | ||
------- | ||
rename_categories | ||
reorder_categories | ||
add_categories | ||
remove_categories | ||
remove_unused_categories | ||
set_categories | ||
as_ordered | ||
as_unordered | ||
get_loc | ||
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. Mentioned above as well: is there something categorical-specific about get_loc ? (the map is fine, that has indeed some specifics that are useful) 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. I just saw that the example mentioned CategoricalIndex specifically. Looks pretty similar though, so I'll remove it. |
||
map | ||
|
||
Attributes | ||
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. Attributes before Methods? 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. Fixed all these |
||
---------- | ||
codes | ||
categories | ||
ordered | ||
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. Ideally we would add here a sentence with something like "For all other methods, see Index", but I am not sure that is allowed in Attributes / Methods sections? 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. I suspect not. I've been thinking of ways to handle this. I'm not worried about people reading the source / in IPython. They already have the code or object. I think in the |
||
""" | ||
|
||
_typ = 'categoricalindex' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,6 +121,9 @@ class IntervalIndex(IntervalMixin, Index): | |
Name to be stored in the index. | ||
copy : boolean, default False | ||
Copy the meta-data | ||
mid | ||
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. is this right? 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. Yeah, if it's just the attribute name the attribute docstring is filled in. But currently that's buggy because |
||
values | ||
is_non_overlapping_monotonic | ||
|
||
Examples | ||
--------- | ||
|
@@ -154,6 +157,16 @@ class IntervalIndex(IntervalMixin, Index): | |
IntervalIndex.from_intervals, IntervalIndex.from_tuples | ||
cut, qcut : convert arrays of continuous data into categoricals/series of | ||
``Interval``. | ||
|
||
Methods | ||
------- | ||
from_arrays | ||
from_tuples | ||
from_breaks | ||
from_intervals | ||
contains | ||
get_loc | ||
|
||
""" | ||
_typ = 'intervalindex' | ||
_comparables = ['name'] | ||
|
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.
I think there is also some other code related to this hack that then could be removed (eg the place where I define the 'class_members_list' config). See cf40991 that added it