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

TST/DEPR: remove .ix from tests\indexing\multiindex\test_loc.py #26451

Merged
merged 4 commits into from
May 19, 2019

Conversation

simonjayhawkins
Copy link
Member

follow on from #26438

i leave this as draft until #26438 is merged, to prevent this one being merged first.

not used iloc for the expected where dropping levels would be required, used df.values instead.

@gfyoung gfyoung added Deprecate Functionality to remove in pandas Index Related to the Index class or subclasses labels May 19, 2019
@jreback
Copy link
Contributor

jreback commented May 19, 2019

@simonjayhawkins can you rebase

@simonjayhawkins simonjayhawkins marked this pull request as ready for review May 19, 2019 17:55
@codecov
Copy link

codecov bot commented May 19, 2019

Codecov Report

Merging #26451 into master will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26451      +/-   ##
==========================================
- Coverage   91.74%   91.73%   -0.01%     
==========================================
  Files         174      174              
  Lines       50746    50746              
==========================================
- Hits        46555    46551       -4     
- Misses       4191     4195       +4
Flag Coverage Δ
#multiple 90.23% <ø> (ø) ⬆️
#single 41.69% <ø> (-0.09%) ⬇️
Impacted Files Coverage Δ
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/frame.py 97.02% <0%> (-0.12%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5a286e4...64d51de. Read the comment docs.

@codecov
Copy link

codecov bot commented May 19, 2019

Codecov Report

Merging #26451 into master will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26451      +/-   ##
==========================================
- Coverage   91.74%   91.73%   -0.01%     
==========================================
  Files         174      174              
  Lines       50746    50748       +2     
==========================================
- Hits        46555    46553       -2     
- Misses       4191     4195       +4
Flag Coverage Δ
#multiple 90.24% <ø> (ø) ⬆️
#single 41.69% <ø> (-0.09%) ⬇️
Impacted Files Coverage Δ
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/frame.py 97.02% <0%> (-0.12%) ⬇️
pandas/core/internals/blocks.py 94.08% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5a286e4...82e0fcc. Read the comment docs.

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

generally we don't want to use DataFrame.values instead prefer .iloc

xp = mi_labels.ix['i']
tm.assert_frame_equal(rs, xp)
# the first 2 rows
expected = DataFrame(
Copy link
Contributor

Choose a reason for hiding this comment

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

use .iloc

xp = mi_labels.ix[:, 'j']
tm.assert_frame_equal(rs, xp)
# 2nd (last) column
expected = DataFrame(df.values[:, [2]], index=df.index, columns=['B'])
Copy link
Contributor

Choose a reason for hiding this comment

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

same, don't directly use .values

@jreback jreback added this to the 0.25.0 milestone May 19, 2019
@simonjayhawkins
Copy link
Member Author

generally we don't want to use DataFrame.values instead prefer .iloc

and then follow with droplevel?

@jreback
Copy link
Contributor

jreback commented May 19, 2019

and then follow with droplevel?

yes I think the 2nd is more idiomatic

In [8]: pd.DataFrame(df.values[[0, 1]], index=['X', 'X'], columns=df.columns)                                                                                                                                                                                                      
Out[8]: 
          i                   j
          A         A         B
X  1.394995 -0.547172  0.790848
X  0.233443 -0.124027  1.298484

In [9]: df.iloc[[0,1]].droplevel(0)                                                                                                                                                                                                                                                
Out[9]: 
          i                   j
          A         A         B
X  1.394995 -0.547172  0.790848
X  0.233443 -0.124027  1.298484

@simonjayhawkins
Copy link
Member Author

the straight sub fails a couple of tests, i've just commited that to show the failing cases.

next commit using droplevel.

@jreback jreback merged commit b99e84f into pandas-dev:master May 19, 2019
@jreback
Copy link
Contributor

jreback commented May 19, 2019

thanks @simonjayhawkins nice clean up!

@simonjayhawkins simonjayhawkins deleted the mi-test_loc-depr-ix branch May 19, 2019 20:45
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 Index Related to the Index class or subclasses
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants