-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DEP: Enforce deprecation of mangle_dup cols and convert_float in read_excel #49089
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
Changes from 9 commits
689db12
5d9a954
c7a0c10
238d133
3cf221d
45cfeb9
a3efa14
98d2b1e
41108bd
7a96a11
24a5582
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -405,7 +405,6 @@ def test_reader_special_dtypes(self, request, read_ext): | |
"FloatCol": [1.25, 2.25, 1.83, 1.92, 0.0000000005], | ||
"BoolCol": [True, False, True, True, False], | ||
"StrCol": [1, 2, 3, 4, 5], | ||
# GH5394 - this is why convert_float isn't vectorized | ||
"Str2Col": ["a", 3, "c", "d", "e"], | ||
"DateCol": [ | ||
datetime(2013, 10, 30), | ||
|
@@ -424,19 +423,11 @@ def test_reader_special_dtypes(self, request, read_ext): | |
|
||
# if not coercing number, then int comes in as float | ||
float_expected = expected.copy() | ||
float_expected["IntCol"] = float_expected["IntCol"].astype(float) | ||
float_expected.loc[float_expected.index[1], "Str2Col"] = 3.0 | ||
with tm.assert_produces_warning( | ||
FutureWarning, | ||
match="convert_float is deprecated", | ||
raise_on_extra_warnings=False, | ||
): | ||
# raise_on_extra_warnings because xlrd raises a PendingDeprecationWarning | ||
# on database job Linux_py37_IO (ci/deps/actions-37-db.yaml) | ||
# See GH#41176 | ||
actual = pd.read_excel( | ||
basename + read_ext, sheet_name="Sheet1", convert_float=False | ||
) | ||
# raise_on_extra_warnings because xlrd raises a PendingDeprecationWarning | ||
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. Tangential to this PR but assuming we ultimately will be removing xlrd as well 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. Yep but did not want to mix too much stuff 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. Looks like the 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. removed |
||
# on database job Linux_py37_IO (ci/deps/actions-37-db.yaml) | ||
# See GH#41176 | ||
actual = pd.read_excel(basename + read_ext, sheet_name="Sheet1") | ||
tm.assert_frame_equal(actual, float_expected) | ||
|
||
# check setting Index (assuming xls and xlsx are the same here) | ||
|
@@ -447,31 +438,12 @@ def test_reader_special_dtypes(self, request, read_ext): | |
exp = expected.set_index(name) | ||
tm.assert_frame_equal(actual, exp) | ||
|
||
# convert_float and converters should be different but both accepted | ||
expected["StrCol"] = expected["StrCol"].apply(str) | ||
actual = pd.read_excel( | ||
basename + read_ext, sheet_name="Sheet1", converters={"StrCol": str} | ||
) | ||
tm.assert_frame_equal(actual, expected) | ||
|
||
no_convert_float = float_expected.copy() | ||
no_convert_float["StrCol"] = no_convert_float["StrCol"].apply(str) | ||
with tm.assert_produces_warning( | ||
FutureWarning, | ||
match="convert_float is deprecated", | ||
raise_on_extra_warnings=False, | ||
): | ||
# raise_on_extra_warnings because xlrd raises a PendingDeprecationWarning | ||
# on database job Linux_py37_IO (ci/deps/actions-37-db.yaml) | ||
# See GH#41176 | ||
actual = pd.read_excel( | ||
basename + read_ext, | ||
sheet_name="Sheet1", | ||
convert_float=False, | ||
converters={"StrCol": str}, | ||
) | ||
tm.assert_frame_equal(actual, no_convert_float) | ||
|
||
# GH8212 - support for converters and missing values | ||
def test_reader_converters(self, read_ext): | ||
|
||
|
@@ -1275,12 +1247,6 @@ def test_read_excel_squeeze(self, read_ext): | |
expected = Series([1, 2, 3], name="a") | ||
tm.assert_series_equal(actual, expected) | ||
|
||
def test_deprecated_kwargs(self, read_ext): | ||
with tm.assert_produces_warning(FutureWarning, raise_on_extra_warnings=False): | ||
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. Could you turn this test into checking that non-keyword arguments here raise? 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. Nice idea - wondering if there's a comprehensive way we should be testing for that (maybe part of test_api) as we do this with more functions 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. Done 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.
Yeah it would be cool to have a test that nails down signature definitions and even alignment between DataFrame/Series methods |
||
pd.read_excel("test1" + read_ext, "Sheet1", 0) | ||
|
||
pd.read_excel("test1" + read_ext) | ||
|
||
def test_no_header_with_list_index_col(self, read_ext): | ||
# GH 31783 | ||
file_name = "testmultiindex" + read_ext | ||
|
Uh oh!
There was an error while loading. Please reload this page.