-
Notifications
You must be signed in to change notification settings - Fork 96
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
Adds Support for Series.value_counts() #49
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
97352cd
adds support for series.value_counts
blaklaybul aa230c5
adds docs for series.value_counts
blaklaybul de243bd
adds tests for series.value_counts
blaklaybul 4af21c5
updates keyerror language
blaklaybul dba2035
adds es docs as an external source
blaklaybul 6476e65
adds parameters for metrics and terms aggs
blaklaybul 2a9c686
adds 2 tests to check for exceptions
blaklaybul 7b1f4d6
explains the size parameter
blaklaybul 18e92db
removes print statements from tests
blaklaybul e574ef0
checks that es_size is a positive integer
blaklaybul f417619
Merge branch 'master' into value-counts
af269a9
implements assert_series_equal
blaklaybul e11e38c
Merge branch 'value-counts' of github.com:blaklaybul/eland into value…
blaklaybul File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
eland.Series.value_counts | ||
=========================== | ||
|
||
.. currentmodule:: eland | ||
|
||
.. automethod:: Series.value_counts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.. _api.series: | ||
|
||
========= | ||
Series | ||
========= | ||
.. currentmodule:: eland | ||
|
||
Computations / descriptive stats | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
.. autosummary:: | ||
:toctree: api/ | ||
|
||
Series.value_counts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# File called _pytest for PyCharm compatability | ||
import eland as ed | ||
from eland.tests.common import TestData | ||
from pandas.util.testing import assert_series_equal | ||
import pytest | ||
|
||
|
||
class TestSeriesValueCounts(TestData): | ||
|
||
def test_value_counts(self): | ||
pd_s = self.pd_flights()['Carrier'] | ||
ed_s = self.ed_flights()['Carrier'] | ||
|
||
pd_vc = pd_s.value_counts() | ||
ed_vc = ed_s.value_counts() | ||
|
||
assert_series_equal(pd_vc, ed_vc) | ||
|
||
def test_value_counts_size(self): | ||
pd_s = self.pd_flights()['Carrier'] | ||
ed_s = self.ed_flights()['Carrier'] | ||
|
||
pd_vc = pd_s.value_counts()[:1] | ||
ed_vc = ed_s.value_counts(es_size=1) | ||
|
||
assert_series_equal(pd_vc, ed_vc) | ||
|
||
def test_value_counts_keyerror(self): | ||
ed_f = self.ed_flights() | ||
with pytest.raises(KeyError): | ||
assert ed_f['not_a_column'].value_counts() | ||
|
||
def test_value_counts_dataframe(self): | ||
# value_counts() is a series method, should raise AttributeError if called on a DataFrame | ||
ed_f = self.ed_flights() | ||
with pytest.raises(AttributeError): | ||
assert ed_f.value_counts() | ||
|
||
def test_value_counts_non_int(self): | ||
ed_s = self.ed_flights()['Carrier'] | ||
with pytest.raises(TypeError): | ||
assert ed_s.value_counts(es_size='foo') | ||
|
||
def test_value_counts_non_positive_int(self): | ||
ed_s = self.ed_flights()['Carrier'] | ||
with pytest.raises(ValueError): | ||
assert ed_s.value_counts(es_size=-9) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
whether we should do defensive programming here is probably something to discuss - this shouldn't block the PR though + we should use type hints to avoid this.
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.
I just thought it would be best to "fail fast" in the top level eland client code instead of passing something to the lower level transport mechanisms and waiting for a cryptic exception to bubble up from there or ES itself.