-
-
Notifications
You must be signed in to change notification settings - Fork 17.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API: Make most arguments for read_html and read_json keyword-ony (#27573
) * Deprecate use of most positional arguments for read_html and read_json * Import pandas._testing instead of pandas.util.testing * Import pandas._testing instead of pandas.util.testing * Update pandas/util/_decorators.py Co-Authored-By: Joris Van den Bossche <jorisvandenbossche@gmail.com> * Change displayed warning message * Update pandas/io/html.py Co-Authored-By: Joris Van den Bossche <jorisvandenbossche@gmail.com> * Update pandas/io/json/_json.py Co-Authored-By: Joris Van den Bossche <jorisvandenbossche@gmail.com> * Restore permissions to v1.0.0.rst * Fix expected warning message in tests for deprecate_nonkeyword_arguments * Reformat too long line * Remove a test too similar to another one. * Update Whatsnew * Fix linting Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
- Loading branch information
1 parent
25e5a74
commit 467e1c2
Showing
7 changed files
with
318 additions
and
49 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
""" | ||
Tests for the deprecated keyword arguments for `read_json`. | ||
""" | ||
|
||
import pandas as pd | ||
import pandas._testing as tm | ||
|
||
from pandas.io.json import read_json | ||
|
||
|
||
def test_deprecated_kwargs(): | ||
df = pd.DataFrame({"A": [2, 4, 6], "B": [3, 6, 9]}, index=[0, 1, 2]) | ||
buf = df.to_json(orient="split") | ||
with tm.assert_produces_warning(FutureWarning): | ||
tm.assert_frame_equal(df, read_json(buf, "split")) | ||
buf = df.to_json(orient="columns") | ||
with tm.assert_produces_warning(FutureWarning): | ||
tm.assert_frame_equal(df, read_json(buf, "columns")) | ||
buf = df.to_json(orient="index") | ||
with tm.assert_produces_warning(FutureWarning): | ||
tm.assert_frame_equal(df, read_json(buf, "index")) | ||
|
||
|
||
def test_good_kwargs(): | ||
df = pd.DataFrame({"A": [2, 4, 6], "B": [3, 6, 9]}, index=[0, 1, 2]) | ||
with tm.assert_produces_warning(None): | ||
tm.assert_frame_equal(df, read_json(df.to_json(orient="split"), orient="split")) | ||
tm.assert_frame_equal( | ||
df, read_json(df.to_json(orient="columns"), orient="columns") | ||
) | ||
tm.assert_frame_equal(df, read_json(df.to_json(orient="index"), orient="index")) |
This file contains 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
Oops, something went wrong.