-
Notifications
You must be signed in to change notification settings - Fork 2
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
Feature/pandas api idxmax #25
Feature/pandas api idxmax #25
Conversation
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 believe that the implementation isn't correct. Take a detailed look at preparse_computations
since I think you aren't handling its output correctly. I haven't reviewed further aspects of this contribution (like tests or docs).
src/pykx/pandas_api/pandas_meta.py
Outdated
@@ -228,6 +228,14 @@ def max(self, axis=0, skipna=True, numeric_only=False): | |||
res | |||
), cols) | |||
|
|||
@convert_result | |||
def idxmax(self, axis=0, skipna=True, numeric_only=False): | |||
tab = self |
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 would remove this line and use self
directly. It's fine if you want to keep it, since it would be consistent with other functions, just a personal taste.
src/pykx/pandas_api/pandas_meta.py
Outdated
@@ -228,6 +228,14 @@ def max(self, axis=0, skipna=True, numeric_only=False): | |||
res | |||
), cols) | |||
|
|||
@convert_result | |||
def idxmax(self, axis=0, skipna=True, numeric_only=False): |
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.
The original API also accepts index
or columns
as possible inputs for axis. As far as I know, preparse_computations
is unable to deal with symbols.
src/pykx/pandas_api/pandas_meta.py
Outdated
def idxmax(self, axis=0, skipna=True, numeric_only=False): | ||
tab = self | ||
res, cols = preparse_computations(tab, axis, skipna, numeric_only) | ||
col_names = _get_numeric_only_subtable_with_bools(tab)[1] if numeric_only else tab.columns |
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 don't get why you use this expression here, isn't col_names
exactly cols
?
src/pykx/pandas_api/pandas_meta.py
Outdated
tab = self | ||
res, cols = preparse_computations(tab, axis, skipna, numeric_only) | ||
col_names = _get_numeric_only_subtable_with_bools(tab)[1] if numeric_only else tab.columns | ||
max_vals = [elems.index(max(elems)) for elems in res] |
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 believe this is broken, elems
has forgotten original indexes. Take a look at this case:
>>> t
pykx.Table(pykx.q('
a b
---
1
1 2
2 3
'))
>>> t.pd()
a b
0 NaN 1
1 1.0 2
2 2.0 3
>>> t.pd().idxmax()
a 2
b 2
dtype: int64
>>> t.idxmax()
pykx.Dictionary(pykx.q('
a| 1
b| 2
'))
Co-authored-by: Jesús López-González <[email protected]>
4f59edd
into
feature/pandas-api-2nd-block-extra
Fix broken link (remote-functions)
Feature idxmax
What does this change introduce?
idxmax
methodParameters:
Returns:
idxmax
on that column / row.It follow the pandas definition. It returns a dictionary instead of a pandas series.
General
src/pykx/pykx.q
andsrc/pykx/reimporter.py
src/pykx/util.py
logic which is used for environment variable.zip
been updatedCode
Testing
Documentation
.md
file associated with it been created?mkdocs.yml