-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
ENH: Add bw_method and ind kwargs to kind='kde' plot method #4298
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
Comments
Given that pandas has to support that version of scipy, you could check for version and go from there, but you need to figure out a version number that is guaranteed to have the argument for As an aside |
see here for how to test for versions: https://github.com/pydata/pandas/wiki/Tips-&-Tricks |
to be very explicit: from distutils.version import LooseVersion
kwargs = dict()
if LooseVersion(scipy.__version__) >= SCIPYVERSION:
kwargs["bw_method"] = self.bw_method
gkde = gaussian_kde(y, **kwargs) Given that it looks like there is only one thing you are setting, you could skip the dictionary creation and do: if RIGHT_VERSION:
gkde = gaussian_kde(y, bw_method=self.bw_method)
else:
gkde = gaussian_kde(y) |
Thanks much. bw_method was added in scipy 0.11.0. I added the version check, corrected the '== None', also added a warning to alert the user for the case when scipy version < 0.11.0 but when bw_method is specified but ignored, and passed the Travis-CI test. |
I rebased and squashed to reduce to one commit, then pushed, and began failing Travis-CI. After some work to determine the problem, I tried to start from the beginning, making a new fork, one commit, passed tests locally, pushed, and again failed Travis-CI tests. It appears to be in code unrelated to my patch: https://travis-ci.org/khgitting/pandas/jobs/9324896 Perhaps current master is not stable? |
this is an unrelelated (recent) failing test |
check back periodically |
@khgitting fixed, rebase and force push should pass travis now |
@cpcloud still failing at same point https://travis-ci.org/khgitting/pandas/jobs/9327972 |
the parent commit for the change u just posted is 54243c7 which is not current master current master is 424e187 |
see the wiki for git tips short version, do: git remote add upstream git://github.com/pydata/pandas.git
git fetch upstream
git rebase upstream/master barring any merge conflicts, this should replay your commits on top of the latest commits in pandas git master |
@cpcloud D'oh; thanks. Pull request passing Travis-CI tests and replayed on top of latest pandas git master: |
One final question on this -- just want to make sure I'm observing proper etiquette. I guess because it passed the Travis-CI test I have a "This pull request can be automatically merged." Should I click to do this? From http://pandas.pydata.org/developers.html , "This request then appears to the repository maintainers, and they will review the code. " |
@khgitting see my comment on your pr |
"This pull request can be automatically merged." will only show up on repositories to which you have push privilges |
closed by #4316 |
It'd be really cool when plotting kde's to be able to set the bandwidth used for the kde and the indices at which it is evaluated. This is done with the bw_method kwarg for scipy.stats.gaussian_kde for scipy >= 0.11, a couple years old now, for the former; a variable ind is created in the pandas class KdePlot's _make_plot method and passed to gkde.evaluate.
Here's a patch which implements this functionality: khgitting/pandas@master...kde_kwargs
I'm having trouble passing the Travis CI tests here: https://travis-ci.org/khgitting/pandas/jobs/9284591
It appears the tests use an older version of scipy where gaussian_kde does not take bw_method kwarg. I'd love to be able to resolve this, but am not sure what the right course of action is. Any advice?
The text was updated successfully, but these errors were encountered: