-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: yield correct Series subclass in df.iterrows() (#13977) #13978
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
Conversation
pls read the instructions. we explicity call for tests. |
392d057
to
eebbaf4
Compare
Ah, sorry. I made sure existing tests passed. Now I also added a new one. |
eebbaf4
to
7777704
Compare
Current coverage is 85.27% (diff: 100%)@@ master #13978 diff @@
==========================================
Files 139 139
Lines 50455 50447 -8
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
- Hits 43026 43018 -8
Misses 7429 7429
Partials 0 0
|
@@ -693,8 +693,9 @@ def iterrows(self): | |||
|
|||
""" | |||
columns = self.columns | |||
_Series = self._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.
call this klass
minor changes. ping when green. |
4c61879
to
9b78a5a
Compare
Revised. Hope it's ok. I did notice some more |
# GH 13977 | ||
df = tm.SubclassedDataFrame({'a': [1]}) | ||
for i, row in df.iterrows(): | ||
tm.assert_series_equal(row, df.loc[i]) |
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 u also add assertIsInstance
explicitly to check it is SubclassedSeries
? assert_series_equal
only checks class identity, not check what it is.
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.
Even though this is already tested in test_indexing_sliced
which tests df.loc
?
Thx for the update. Yes fixing relevant cases are appreciated (OK for separate PR). The remaining normal constructor is mostly because of historical reason, and can be replaced to |
But what are relevant cases? If Using Python's |
It's simply because no one can take a time to do it (add tests). Note that sigatures must be changed sometimes, see #13208. |
b62559e
to
2794c37
Compare
Thanks, will look into it. |
Adding just I added a RFC commit with one proposed solution. It basically makes only DataFrame inherit DataFrame's _metadata properties, Series Series', and so on. I don't know whether this opposes any established behavior / documentation. Doesn't seem to. The tests will pass. 🙏 |
the inheriting of metadata should be on a like object. However this would belong in another PR. |
@kernc thx for theck. I've thought |
2794c37
to
8d0e8fc
Compare
So this appears to be it for this PR. I'll be opening the other one shortly. Thanks. |
e052101
to
2820315
Compare
2820315
to
47f5894
Compare
47f5894
to
9aaac80
Compare
lgtm. ping on green. |
So this is green. I'm not sure why Xcode build is marked as failed. |
thanks! |
git diff upstream/master | flake8 --diff