Skip to content
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

Merged
merged 40 commits into from
Dec 12, 2019
Merged

DEPR: remove ix #27620

merged 40 commits into from
Dec 12, 2019

Conversation

jbrockmendel
Copy link
Member

@jbrockmendel jbrockmendel commented Jul 27, 2019

  • Needs release note
  • Needs geopandas compat
  • Need to remove ix asvs

filterwarnings("ignore", "\\n.ix", FutureWarning)
return f.ix[i]

# TODO: this used to be f.ix[i]; is loc-then-iloc correct here?
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member

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

Copy link
Member

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]:
Copy link
Member

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):
Copy link
Member

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

Copy link
Member Author

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]
Copy link
Member

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

@WillAyd WillAyd added the Deprecate Functionality to remove in pandas label Jul 27, 2019
@@ -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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @jorisvandenbossche

@jbrockmendel can you open an issue on geopandas tracker?

Copy link
Member Author

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

Copy link
Member

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.

@jreback jreback added this to the 1.0 milestone Jul 27, 2019
@jreback
Copy link
Contributor

jreback commented Jul 27, 2019

@jbrockmendel lgtm. can you PR to geopandas to fix?

@jreback
Copy link
Contributor

jreback commented Jul 27, 2019

can you add the issue number at the top

def __iter__(self):
raise NotImplementedError("ix is not iterable")

def __getitem__(self, key):
Copy link
Member

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)

Copy link
Member Author

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?

Copy link
Member

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.

filterwarnings("ignore", "\\n.ix", FutureWarning)
return f.ix[i]

# TODO: this used to be f.ix[i]; is loc-then-iloc correct here?
Copy link
Member

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
Copy link
Member

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"]
Copy link
Member

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)

@@ -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")
Copy link
Member

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.

@@ -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]]
Copy link
Member

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)

@jbrockmendel
Copy link
Member Author

closing, will revisit once ix deprecation is enforced

@jorisvandenbossche
Copy link
Member

What do you mean exactly? I think we want to remove it now?

@jbrockmendel
Copy link
Member Author

You're right, it was the NDFrameIndexer.__getitem__ that we're keeping around a little while longer until geopandas stops relying on it. Either way, this is low priority for me at the moment.

@jorisvandenbossche
Copy link
Member

Either way, this is low priority for me at the moment.

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)

Copy link
Member

@WillAyd WillAyd left a 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?

@@ -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):
Copy link
Member

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?

Copy link
Member Author

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

@jbrockmendel
Copy link
Member Author

rebased

@jbrockmendel
Copy link
Member Author

@jorisvandenbossche is the geopandas compat problem resolved? if so, does this just need a whatsnew note?

@jbrockmendel
Copy link
Member Author

@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
Copy link
Contributor

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

# TODO: this used to be f.ix[i]; is loc-then-iloc correct here?
try:
return f.loc[i]
except KeyError:
Copy link
Contributor

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

@jreback
Copy link
Contributor

jreback commented Dec 8, 2019

lgtm generally, 2 items which i think should be done in this PR

@jbrockmendel
Copy link
Member Author

updated+green

@jreback
Copy link
Contributor

jreback commented Dec 10, 2019

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.

Copy link
Member

@WillAyd WillAyd left a 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

@jorisvandenbossche
Copy link
Member

Yes, let's handle further testing clean-up in a follow-up issue.

@jorisvandenbossche is the geopandas compat problem resolved?

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)

@jorisvandenbossche jorisvandenbossche merged commit a5c992b into pandas-dev:master Dec 12, 2019
@jorisvandenbossche
Copy link
Member

jorisvandenbossche commented Dec 12, 2019

@jbrockmendel thanks a lot for this!

proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants