-
-
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
DEPR: remove ix #27620
DEPR: remove ix #27620
Conversation
jbrockmendel
commented
Jul 27, 2019
•
edited
Loading
edited
- Needs release note
- Needs geopandas compat
- Need to remove ix asvs
pandas/tests/indexing/common.py
Outdated
filterwarnings("ignore", "\\n.ix", FutureWarning) | ||
return f.ix[i] | ||
|
||
# TODO: this used to be f.ix[i]; is loc-then-iloc correct here? |
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 should just be .iloc
looking at docstring?
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.
that was my first guess too, but that failed
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.
longer term, we should then probably clean up the tests using this get_value
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.
Hmm do you know how many tests this failed? Wonder if its just a problem with the test
@@ -134,8 +134,7 @@ def test_scalar_non_numeric(self): | |||
|
|||
# these should prob work | |||
# and are inconsisten between series/dataframe ATM | |||
# for idxr in [lambda x: x.ix, | |||
# lambda x: x]: | |||
# for idxr in [lambda x: x]: |
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 can just delete this altogether? Looks like it was specific to .ix
?
@@ -462,71 +462,6 @@ def test_iloc_setitem_dups(self): | |||
df.iloc[[1, 0], [0, 1]] = df.iloc[[1, 0], [0, 1]].reset_index(drop=True) | |||
tm.assert_frame_equal(df, expected) | |||
|
|||
def test_iloc_getitem_frame(self): |
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.
Do we still have coverage for this? Looks like main intention was .iloc testing so ix was secondary
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.
ill have to do a readthrough to check. its not entirely easy to tell what kind of coverage we have for indexing
# don't allow not string inserts | ||
with pytest.raises(TypeError): | ||
with catch_warnings(record=True): | ||
df.loc[100.0, :] = df.ix[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.
Maybe should also replace the rhs side of these with scalar values
pandas/tests/test_downstream.py
Outdated
@@ -123,6 +123,7 @@ def test_geopandas(): | |||
assert geopandas.read_file(fp) is not None | |||
|
|||
|
|||
@pytest.mark.xfail(reason="ix-only methods have been removed from _NDFrameIndexer") |
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.
@jbrockmendel can you open an issue on geopandas tracker?
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.
Vague plan is to wait for Joris to get back and advise on how to proceed
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.
There is already an open issue for that: geopandas/geopandas#1042
My advice is to keep compatibility with released geopandas for now (see the comment I made above on a specific method of NDFrameIndexer). I know geopandas shouldn't be using this (I opened a PR to clean it up: geopandas/geopandas#1072), but it is, and given we know that, it would be nice to not break directly.
@jbrockmendel lgtm. can you PR to geopandas to fix? |
can you add the issue number at the top |
def __iter__(self): | ||
raise NotImplementedError("ix is not iterable") | ||
|
||
def __getitem__(self, key): |
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.
Could we keep this method? (or part of it, for compat with released geopandas)
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.
That makes sense. Possibly with a warning telling users they need to upgrade geopandas?
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, that sounds good. But maybe start having it as a DeprecationWarning? Then we can easily switch to FutureWarning once there is an actual geopandas release.
pandas/tests/indexing/common.py
Outdated
filterwarnings("ignore", "\\n.ix", FutureWarning) | ||
return f.ix[i] | ||
|
||
# TODO: this used to be f.ix[i]; is loc-then-iloc correct here? |
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.
longer term, we should then probably clean up the tests using this get_value
df["A"] # cache series | ||
df.ix["Hello Friend"] = df.ix[0] | ||
assert "Hello Friend" in df["A"].index | ||
assert "Hello Friend" in df["B"].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.
Should this be kept but with something else as ix?
Also, need to remove the filterwarnings mark I think
expected = DataFrame(dict({"A": [0, 2, 4], "B": [0, 2, 4]})) | ||
df = df_orig.copy() | ||
with catch_warnings(record=True): | ||
df.ix[:, "B"] = df.ix[:, "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.
is this tested for loc
? (otherwise keep test but with loc? same for the ones below)
pandas/tests/test_downstream.py
Outdated
@@ -123,6 +123,7 @@ def test_geopandas(): | |||
assert geopandas.read_file(fp) is not None | |||
|
|||
|
|||
@pytest.mark.xfail(reason="ix-only methods have been removed from _NDFrameIndexer") |
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.
There is already an open issue for that: geopandas/geopandas#1042
My advice is to keep compatibility with released geopandas for now (see the comment I made above on a specific method of NDFrameIndexer). I know geopandas shouldn't be using this (I opened a PR to clean it up: geopandas/geopandas#1072), but it is, and given we know that, it would be nice to not break directly.
pandas/tests/frame/test_indexing.py
Outdated
@@ -402,12 +401,6 @@ def test_getitem_ix_mixed_integer(self): | |||
expected = df.loc[df.index[:-1]] | |||
assert_frame_equal(result, expected) | |||
|
|||
with catch_warnings(record=True): | |||
simplefilter("ignore", FutureWarning) | |||
result = df.ix[[1, 10]] |
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.
replace with loc? (the above loc seems to be do something slightly different)
closing, will revisit once ix deprecation is enforced |
What do you mean exactly? I think we want to remove it now? |
You're right, it was the |
OK, but let's keep the PR open for now. Then it is clearer that there is already a PR to start from in case somebody wants to do the work (and I think we still want this done for 1.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.
Can you merge master?
pandas/tests/frame/test_indexing.py
Outdated
@@ -852,55 +802,6 @@ def test_delitem_corner(self, float_frame): | |||
del f["B"] | |||
assert len(f.columns) == 2 | |||
|
|||
def test_getitem_fancy_2d(self, float_frame): |
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.
Are these tests covered elsewhere or just specific to .ix?
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.
Most of these mix loc/iloc behavior, so are specific to ix
rebased |
@jorisvandenbossche is the geopandas compat problem resolved? if so, does this just need a whatsnew note? |
@jorisvandenbossche gentle ping, we're running out of deprecations to enforce |
self.df.ix[50:1000, 20:50] = np.nan | ||
self.df.ix[2000:3000] = np.nan | ||
self.df.ix[:, 60:70] = np.nan | ||
self.df.iloc[50:1000, 20:50] = np.nan |
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 would remove the warnings catching if its no longer necessary
pandas/tests/indexing/common.py
Outdated
# TODO: this used to be f.ix[i]; is loc-then-iloc correct here? | ||
try: | ||
return f.loc[i] | ||
except KeyError: |
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.
err, this is not good here. can you separate the cases into ones for .loc and ones for .iloc
lgtm generally, 2 items which i think should be done in this PR |
updated+green |
I am ok with merging this, long overdue. I would say create an issue to make sure that for .loc we have enough tests that absolute expected cases (rather than .ix comparisons). @pandas-dev/pandas-core any objections. |
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.
lgtm. agreed long overdue - thanks for tackling this @jbrockmendel
Yes, let's handle further testing clean-up in a follow-up issue.
It's still in a released version (the same as when we discussed this a few months ago), but it is already fixed in the meantime. I would prefer to keep the compat code here a little bit longer (the geopandas version that fixes it is only recently released) |
@jbrockmendel thanks a lot for this! |