-
-
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: enable docstring on DataFrame.columns/index #20385
DOC: enable docstring on DataFrame.columns/index #20385
Conversation
pandas/_libs/properties.pyx
Outdated
Py_ssize_t axis | ||
|
||
def __init__(self, axis=0): | ||
cdef readonly: | ||
object __doc__ |
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.
Can this go under the same def readonly
block as axis?
And do we want object
or str
for the type?
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.
whoops, the above cdef readonly
is a typo, I meant to keep it as readonly
.
I am not fully sure if it is actually needed for axis
, or if we can also make it readonly
(I would think it is never modified internally, bot not sure)
For the object
, it is what is done for CachedProperties
above as well. My cython is not good enough to really know the consequences. I think we usually use object
for strings in our cython code.
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.
If the test pass with using readonly
for axis
, I will combine them in one cdef readonly
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.
object
vs str
is pretty harmless in this case. I'd advocate sticking with object
for now b/c then we don't need to worry about potential py2/py3 bytes/unicode corner cases.
Codecov Report
@@ Coverage Diff @@
## master #20385 +/- ##
==========================================
+ Coverage 91.77% 91.8% +0.02%
==========================================
Files 152 152
Lines 49205 49215 +10
==========================================
+ Hits 45159 45181 +22
+ Misses 4046 4034 -12
Continue to review full report at Codecov.
|
pandas/core/generic.py
Outdated
@@ -278,7 +278,7 @@ def _setup_axes(cls, axes, info_axis=None, stat_axis=None, aliases=None, | |||
if build_axes: | |||
|
|||
def set_axis(a, i): | |||
setattr(cls, a, properties.AxisProperty(i)) | |||
setattr(cls, a, properties.AxisProperty(i, a)) |
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 setattr
has always bothered me. It kind of makes since in a general-case world with PanelND
, but if we're only interested in Series/DataFrame/[barely-]Panel
wouldn't it be clearer just to write:
class DataFrame(NDFrame):
index = properties.AxisProperty(0)
columns = properties.AxisProperty(1)
?
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.
Yep, fully agree that if we only have 1D/2D this makes much more sense. But maybe we should only clean that up when Panel is removed?
Follow-up on #18196, similar to #19991
Didn't add an actual full docstring yet, but this already gives:
instead of (on master, on 0.22 this raises an exception):