-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
API: Remove integer position args from xy for plotting #20371
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
Closed
masongallo
wants to merge
2
commits into
pandas-dev:master
from
masongallo:remove-positions-plotting
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -205,9 +205,6 @@ def test_donot_overwrite_index_name(self): | |
def test_plot_xy(self): | ||
# columns.inferred_type == 'string' | ||
df = self.tdf | ||
self._check_data(df.plot(x=0, y=1), df.set_index('A')['B'].plot()) | ||
self._check_data(df.plot(x=0), df.set_index('A').plot()) | ||
self._check_data(df.plot(y=0), df.B.plot()) | ||
self._check_data(df.plot(x='A', y='B'), df.set_index('A').B.plot()) | ||
self._check_data(df.plot(x='A'), df.set_index('A').plot()) | ||
self._check_data(df.plot(y='B'), df.B.plot()) | ||
|
@@ -1019,7 +1016,6 @@ def test_plot_scatter(self): | |
columns=['x', 'y', 'z', 'four']) | ||
|
||
_check_plot_works(df.plot.scatter, x='x', y='y') | ||
_check_plot_works(df.plot.scatter, x=1, y=2) | ||
|
||
with pytest.raises(TypeError): | ||
df.plot.scatter(x='x') | ||
|
@@ -1054,17 +1050,15 @@ def test_plot_scatter_with_c(self): | |
index=list(string.ascii_letters[:6]), | ||
columns=['x', 'y', 'z', 'four']) | ||
|
||
axes = [df.plot.scatter(x='x', y='y', c='z'), | ||
df.plot.scatter(x=0, y=1, c=2)] | ||
for ax in axes: | ||
# default to Greys | ||
assert ax.collections[0].cmap.name == 'Greys' | ||
axes = df.plot.scatter(x='x', y='y', c='z') | ||
|
||
if self.mpl_ge_1_3_1: | ||
# default to Greys | ||
assert axes.collections[0].cmap.name == 'Greys' | ||
|
||
# n.b. there appears to be no public method to get the colorbar | ||
# label | ||
assert ax.collections[0].colorbar._label == 'z' | ||
if self.mpl_ge_1_3_1: | ||
# n.b. there appears to be no public method to get the colorbar | ||
# label | ||
assert axes.collections[0].colorbar._label == 'z' | ||
|
||
cm = 'cubehelix' | ||
ax = df.plot.scatter(x='x', y='y', c='z', colormap=cm) | ||
|
@@ -1075,7 +1069,7 @@ def test_plot_scatter_with_c(self): | |
assert ax.collections[0].colorbar is None | ||
|
||
# verify that we can still plot a solid color | ||
ax = df.plot.scatter(x=0, y=1, c='red') | ||
ax = df.plot.scatter(x='x', y='y', c='red') | ||
assert ax.collections[0].colorbar is None | ||
self._check_colors(ax.collections, facecolors=['r']) | ||
|
||
|
@@ -2172,14 +2166,27 @@ def test_invalid_kind(self): | |
|
||
@pytest.mark.parametrize("x,y", [ | ||
(['B', 'C'], 'A'), | ||
('A', ['B', 'C']) | ||
('A', ['B', 'C']), | ||
(0, 'A'), | ||
('A', 0), | ||
(0, 1) | ||
]) | ||
def test_invalid_xy_args(self, x, y): | ||
# GH 18671 | ||
# GH 18671 and # GH 20056 | ||
df = DataFrame({"A": [1, 2], 'B': [3, 4], 'C': [5, 6]}) | ||
with pytest.raises(ValueError): | ||
df.plot(x=x, y=y) | ||
|
||
@pytest.mark.parametrize("x,y,colnames", [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add a test that checks the raise when passing ints and a non-int index |
||
(0, 1, [0, 1]), | ||
(1, 'A', ['A', 1]) | ||
]) | ||
def test_xy_args_ints(self, x, y, colnames): | ||
# GH 20056 | ||
df = DataFrame({"A": [1, 2], 'B': [3, 4]}) | ||
df.columns = colnames | ||
_check_plot_works(df.plot, x=x, y=y) | ||
|
||
@pytest.mark.parametrize("x,y", [ | ||
('A', 'B'), | ||
('B', 'A') | ||
|
@@ -2255,9 +2262,6 @@ def test_pie_df(self): | |
ax = _check_plot_works(df.plot.pie, y='Y') | ||
self._check_text_labels(ax.texts, df.index) | ||
|
||
ax = _check_plot_works(df.plot.pie, y=2) | ||
self._check_text_labels(ax.texts, df.index) | ||
|
||
# _check_plot_works adds an ax so catch warning. see GH #13188 | ||
with tm.assert_produces_warning(UserWarning): | ||
axes = _check_plot_works(df.plot.pie, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@TomAugspurger we should be able to blow this code away as we > 1.4.3, yes (separate PR)