Skip to content

BUG:reorder type check/conversion so wide_to_long handles str arg for… #22490

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

Merged
merged 2 commits into from
Sep 23, 2018
Merged

BUG:reorder type check/conversion so wide_to_long handles str arg for… #22490

merged 2 commits into from
Sep 23, 2018

Conversation

csmcallister
Copy link
Contributor

@csmcallister csmcallister commented Aug 23, 2018

closes #22468

  • closes #xxxx
  • tests added / passed
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

@csmcallister
Copy link
Contributor Author

#22468

This reorders the list type check/conversion to occur before the stubname membership test. This will prevent the ValueError in the cases where a column name is a substring of a stubname when a string is passed to the stubnames argument of wide_to_long().

Also, this is my first PR and I love pandas!

@gfyoung
Copy link
Member

gfyoung commented Aug 24, 2018

@csmcallister

  • Great to hear you love pandas!
  • Good start, but we're going to need a test and whatsnew entry as well

@gfyoung gfyoung added Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Aug 24, 2018
@csmcallister
Copy link
Contributor Author

Of course! I can get to those things later this day. Thank you so much for pointing me in the right direction.

@pep8speaks
Copy link

pep8speaks commented Aug 24, 2018

Hello @csmcallister! Thanks for updating the PR.

Comment last updated on September 07, 2018 at 00:48 Hours UTC

@codecov
Copy link

codecov bot commented Aug 24, 2018

Codecov Report

Merging #22490 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #22490   +/-   ##
=======================================
  Coverage   92.04%   92.04%           
=======================================
  Files         169      169           
  Lines       50773    50773           
=======================================
  Hits        46734    46734           
  Misses       4039     4039
Flag Coverage Δ
#multiple 90.45% <100%> (ø) ⬆️
#single 42.23% <0%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/reshape/melt.py 97.34% <100%> (ø) ⬆️

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 0f656f7...58df814. Read the comment docs.

@@ -0,0 +1,55 @@
# -*- coding: utf-8 -*-
Copy link
Contributor

Choose a reason for hiding this comment

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

can you move existing wide_to_long tests from other reshaping tests to here (in test_melt)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for all the help on my PR!

I made the style fixes and moved the test to the TestWideToLong class in test_melt.py. I then ran pytest locally and passed. Before updating the PR, I merged master changes from the past few days to my branch doing:
git checkout master
git pull upstream master --ff-only
git checkout my-branch-name
git fetch upstream
git merge upstream/master
There weren't any conflicts, but to be safe I figured I'd run test_melt.py again. That's when I got the following error:

(pandas-dev) Charless-MacBook-Air:reshape mcallistercs$ pytest test_melt.py 
Traceback (most recent call last):
  File "/Users/mcallistercs/virtualenvs/pandas-dev/lib/python3.6/site-packages/_pytest/config/__init__.py", line 377, in _getconftestmodules
    return self._path2confmods[path]
KeyError: local('/Users/mcallistercs/Desktop/Github/pandas-csmcallister/pandas/tests/reshape/test_melt.py')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/Users/mcallistercs/virtualenvs/pandas-dev/lib/python3.6/site-packages/_pytest/config/__init__.py", line 377, in _getconftestmodules
    return self._path2confmods[path]
KeyError: local('/Users/mcallistercs/Desktop/Github/pandas-csmcallister/pandas/tests/reshape')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/Users/mcallistercs/virtualenvs/pandas-dev/lib/python3.6/site-packages/_pytest/config/__init__.py", line 408, in _importconftest
    return self._conftestpath2mod[conftestpath]
KeyError: local('/Users/mcallistercs/Desktop/Github/pandas-csmcallister/pandas/conftest.py')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/Users/mcallistercs/virtualenvs/pandas-dev/lib/python3.6/site-packages/_pytest/config/__init__.py", line 414, in _importconftest
    mod = conftestpath.pyimport()
  File "/Users/mcallistercs/virtualenvs/pandas-dev/lib/python3.6/site-packages/py/_path/local.py", line 668, in pyimport
    __import__(modname)
  File "/Users/mcallistercs/virtualenvs/pandas-dev/lib/python3.6/site-packages/_pytest/assertion/rewrite.py", line 226, in load_module
    py.builtin.exec_(co, mod.__dict__)
  File "/Users/mcallistercs/Desktop/Github/pandas-csmcallister/pandas/conftest.py", line 458, in <module>
    from hypothesis import strategies as st
ModuleNotFoundError: No module named 'hypothesis'
ERROR: could not load /Users/mcallistercs/Desktop/Github/pandas-csmcallister/pandas/conftest.py

I then opened a new shell and pip installed hypothesis, but still received the same error when trying to test again. Any help would be greatly appreciated!

@codecov
Copy link

codecov bot commented Sep 7, 2018

Codecov Report

Merging #22490 into master will increase coverage by <.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #22490      +/-   ##
==========================================
+ Coverage   92.04%   92.04%   +<.01%     
==========================================
  Files         169      169              
  Lines       50783    50782       -1     
==========================================
+ Hits        46741    46744       +3     
+ Misses       4042     4038       -4
Flag Coverage Δ
#multiple 100% <ø> (+9.54%) ⬆️
#single 42.26% <0%> (+0.04%) ⬆️
Impacted Files Coverage Δ
pandas/core/reshape/melt.py 97.34% <0%> (ø) ⬆️
pandas/tslib.py 100% <0%> (ø) ⬆️
pandas/io/formats/latex.py 100% <0%> (ø) ⬆️
pandas/lib.py 100% <0%> (ø) ⬆️
pandas/core/categorical.py 100% <0%> (ø) ⬆️
pandas/parser.py 100% <0%> (ø) ⬆️
pandas/io/sas/sas_constants.py 100% <0%> (ø) ⬆️
pandas/types/concat.py 100% <0%> (ø) ⬆️
pandas/tseries/plotting.py 100% <0%> (ø) ⬆️
pandas/tseries/converter.py 100% <0%> (ø) ⬆️
... and 129 more

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 1a798be...32c3a64. Read the comment docs.

@csmcallister
Copy link
Contributor Author

Well, this is embarrassing. Copying and pasting jacked up the indentation and angered pep8speaks. Weird since because beforehand I ran git diff upstream/master -u -- "*.py" | flake8 --diff and nothing printed out.

@jreback jreback added this to the 0.24.0 milestone Sep 18, 2018
@jreback
Copy link
Contributor

jreback commented Sep 18, 2018

looks good. can you rebase on master and push again. ping on green.

… stubnames. GH22468

DOC:Updating whatsnew (#22468)

TST:test bug fix and old functionality (#22468)

CLN:complying with PEP8 isssues (#22468)

TST: Moved wide_to_long test to test_melt.py and fixed linting issues (#22468)

CLN: Adjusted indentation for linting (#22468)

CLN: Adjusted spacing for linting (#22468)
@codecov
Copy link

codecov bot commented Sep 19, 2018

Codecov Report

Merging #22490 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #22490   +/-   ##
=======================================
  Coverage   92.18%   92.18%           
=======================================
  Files         169      169           
  Lines       50820    50820           
=======================================
  Hits        46850    46850           
  Misses       3970     3970
Flag Coverage Δ
#multiple 90.6% <100%> (ø) ⬆️
#single 42.38% <0%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/reshape/melt.py 97.34% <100%> (ø) ⬆️

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 4cc0a71...1fb07b4. Read the comment docs.

@csmcallister
Copy link
Contributor Author

Rebased on master, squashing commits into one. @jreback

@jreback
Copy link
Contributor

jreback commented Sep 23, 2018

not sue why failing, can you merge master and try again

@csmcallister
Copy link
Contributor Author

Just merged and trying again.

@jreback jreback merged commit 2ab57b2 into pandas-dev:master Sep 23, 2018
@jreback
Copy link
Contributor

jreback commented Sep 23, 2018

thanks @csmcallister

@csmcallister csmcallister deleted the fix-melt-bug branch September 23, 2018 22:48
Sup3rGeo pushed a commit to Sup3rGeo/pandas that referenced this pull request Oct 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

wide_to_long mishandles string arg for stubnames
4 participants