-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Subclassing improvements #12308
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
Subclassing improvements #12308
Conversation
@@ -279,7 +279,12 @@ def _isnull_ndarraylike(obj): | |||
# box | |||
if isinstance(obj, ABCSeries): | |||
from pandas import Series | |||
result = Series(result, index=obj.index, name=obj.name, copy=False) | |||
if isinstance(obj, Series): | |||
result = obj._constructor_sliced( |
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.
lots of repeatitive code here. I don't think you need anything except replace Series with obj._constructor_sliced
no?
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.
Yes, changed that.
So I have made most of the changes you suggested (also see comments above).
I do not really understand what you mean by your comment on the change in ops.py, could you explain? |
@cldy thanks for this. I will have a closer look prob next week. |
pls rebase/update |
btw, you will want to squash this down and simply rebase on master to fast-forward yourself. |
Current coverage is 88.69%@@ master #12308 diff @@
========================================
Files 138 276 +138
Lines 50712 134409 +83697
Methods 0 0
Branches 0 0
========================================
+ Hits 42714 119218 +76504
- Misses 7998 15191 +7193
Partials 0 0
|
Sorrry this is taking so long. The rebase and squash turned out to be more complicated than expected, but is now done (locally). I am still at a bit of a loss as to why the Travis build fails. The error is apparently due to the locale setting zh_CN.GB18030 (No such file or directory). I will have a closer look at this at the beginning of next week, but would be grateful for a hint. |
@cldy you need to rebase on master. you should only have your commits here. |
6008ae0
to
cbea137
Compare
@@ -333,7 +333,7 @@ def notnull(obj): | |||
pandas.isnull : boolean inverse of pandas.notnull | |||
""" | |||
res = isnull(obj) | |||
if lib.isscalar(res): | |||
if np.isscalar(res): |
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.
you are reversing changes previously made.
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.
Yes, thanks, fixed that.
Rebase done, still haven't figured out the locale error ... |
4f792c3
to
f8e46ab
Compare
The locale error occurs only in my Travis, but the build seems to pass here. Also, I have squashed the commits. |
@@ -130,6 +130,10 @@ def _constructor(self): | |||
|
|||
_constructor_sliced = DataFrame | |||
|
|||
_constructor_expanddim = _constructor |
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.
Dupe, and is this tested somewhere? The definition looks inappropriate.
I think it's better to split the change to 2 parts which can be done with current If subclassing mechanism is being changed, |
Sorry that this is taking so long ... I am now working on it, but am currently having some problems with the (recent?) changes to sparse data types. |
I have fixed the issues with Sparse data types, but I still get a number of these errors in Travis:
I don't quite understand how this is related to the changes I made. Any help would be very much appreciated. |
make sure you rebased on master |
git |
result = value_counts(self, sort=sort, ascending=ascending, | ||
normalize=normalize, bins=bins, dropna=dropna) | ||
return result | ||
|
||
if isinstance(self, Index): |
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.
use gt.ABCIndexClass
(its already imported)
can you rebase / update? |
@cldy closing; I would like to see this merged, but can we do this in pieces (e.g. smaller discrete changes). Certainly open an issue with a list of todo's that we can then check off though. |
Addresses indexing issues related to subclassing (#11559).
Also made some changes to base, groupby, reshape, strings.
So for example, if df was a SubclassedDataFrame and s was a SubclassedSeries
df.groupby('A').apply(lambda x: x)
and
s.value_counts()
would return SubclassedDataFrame and SubclassedSeries instances, respectively.