-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
ENH: inconsistent naming convention for read_excel column selection (#4988) #16488
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 1 commit
52f2c11
d681a0e
a4341de
e985488
d58669c
058177b
03593a7
6649157
ef487d9
e60dc4c
7efc4e8
4ca29f4
92d0799
fbdae2d
d4f80b0
9b0ea41
d31ffdb
03d44f3
e437ad5
58f4454
ee8346d
9d7afa7
a67c7aa
cab2b6b
e0a127a
e3ee186
d419be4
fb47ee5
7b106e4
a7760e3
4ec98d8
a19f9fa
72e0d1f
fc4408b
db419bf
8d092d9
5f312da
06f8347
ff0d1f4
31e67d5
9e620bc
473615e
ce3b0c3
18c316b
50a62c1
91057f3
bf99975
697d026
10c17d4
dfebd8a
2b44868
722b386
73930c5
9fdea65
789f7bb
5aba665
ec6bf6d
dc716b0
d6c3189
5682a05
8025c0c
f07a002
440e6a6
f299ea2
5948c01
dd7dc30
a525222
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- removed usecols mention in Other Enhancments section, remains in Deprecations. - removed test_parse_* test methods in favor of test_usecols_* methods. - changed parse_cols to usecols in test_read_one_empty_col_* instead of catching warning.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,36 +166,38 @@ def setup_method(self, method): | |
self.check_skip() | ||
super(ReadingTestsBase, self).setup_method(method) | ||
|
||
def test_parse_cols_int(self): | ||
|
||
def test_usecols_int(self): | ||
# GH4988: inconsistent naming convention for read_excel column select | ||
dfref = self.get_csv_refdf('test1') | ||
dfref = dfref.reindex(columns=['A', 'B', 'C']) | ||
df1 = self.get_exceldf('test1', 'Sheet1', index_col=0, parse_cols=3) | ||
df1 = self.get_exceldf('test1', 'Sheet1', index_col=0, usecols=3) | ||
df2 = self.get_exceldf('test1', 'Sheet2', skiprows=[1], index_col=0, | ||
parse_cols=3) | ||
# TODO add index to xls file) | ||
tm.assert_frame_equal(df1, dfref, check_names=False) | ||
tm.assert_frame_equal(df2, dfref, check_names=False) | ||
|
||
def test_parse_cols_list(self): | ||
|
||
def test_usecols_list(self): | ||
# GH4988: inconsistent naming convention for read_excel column select | ||
dfref = self.get_csv_refdf('test1') | ||
dfref = dfref.reindex(columns=['B', 'C']) | ||
df1 = self.get_exceldf('test1', 'Sheet1', index_col=0, | ||
parse_cols=[0, 2, 3]) | ||
df2 = self.get_exceldf('test1', 'Sheet2', skiprows=[1], index_col=0, | ||
parse_cols=[0, 2, 3]) | ||
# TODO add index to xls file) | ||
usecols=[0, 2, 3]) | ||
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): | ||
df3 = self.get_exceldf('test1', 'Sheet1', index_col=0, | ||
parse_cols=[0, 2, 3]) | ||
|
||
tm.assert_frame_equal(df1, dfref, check_names=False) | ||
tm.assert_frame_equal(df2, dfref, check_names=False) | ||
|
||
def test_parse_cols_str(self): | ||
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. leave the original tests structure (sure you can change the name to conform), but don't change the tests (in THIS PR). 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. tests are back to original but with changed function & kwarg names. |
||
|
||
def test_usecols_str(self): | ||
# GH4988: inconsistent naming convention for read_excel column select | ||
dfref = self.get_csv_refdf('test1') | ||
|
||
df1 = dfref.reindex(columns=['A', 'B', 'C']) | ||
df2 = self.get_exceldf('test1', 'Sheet1', index_col=0, | ||
parse_cols='A:D') | ||
df2 = self.get_exceldf('test1', 'Sheet1', usecol=0, usecols='A:D') | ||
df3 = self.get_exceldf('test1', 'Sheet2', skiprows=[1], index_col=0, | ||
parse_cols='A:D') | ||
# TODO add index to xls, read xls ignores index name ? | ||
|
@@ -465,14 +467,14 @@ def test_read_one_empty_col_no_header(self): | |
actual_header_none = read_excel( | ||
path, | ||
'no_header', | ||
parse_cols=[0], | ||
usecols=[0], | ||
header=None | ||
) | ||
|
||
actual_header_zero = read_excel( | ||
path, | ||
'no_header', | ||
parse_cols=[0], | ||
usecols=[0], | ||
header=0 | ||
) | ||
expected = DataFrame() | ||
|
@@ -494,14 +496,14 @@ def test_read_one_empty_col_with_header(self): | |
actual_header_none = read_excel( | ||
path, | ||
'with_header', | ||
parse_cols=[0], | ||
usecols=[0], | ||
header=None | ||
) | ||
|
||
actual_header_zero = read_excel( | ||
path, | ||
'with_header', | ||
parse_cols=[0], | ||
usecols=[0], | ||
header=0 | ||
) | ||
expected_header_none = DataFrame(pd.Series([0], dtype='int64')) | ||
|
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.
so you need to change ALL tests to use the new one (usecols), except for a single test to actually hit the deprecation.