-
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
Add count and add prefix and sufix implementation #12
Conversation
pcount = df.count(axis=1) | ||
|
||
print(pcount) | ||
assert int(qcount[0]) == int(pcount[0]) |
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.
Why don't we fully compare qcount
and pcount
instead of just checking the very first index?
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.
This is the reason we have to decouple pandas cases and q: In accordance with the correspondence between q nulls and Python nulls established in the .pd conversion, the empty string is regarded as a null value for columns of type symbol.
|
||
print(pcount) | ||
assert int(qcount[0]) == int(pcount[0]) | ||
assert int(qcount[1]) == 1 |
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'm not sure if this adds value, since I think it's ok to assume that the pandas implementation is correct.
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 same as before, in the case of symbols we have to write the case by hand because the conversion is not done automatically. I could create an equivalent Pandas table and not use the automatic switch from Pandas to pykx. But perhaps this way the special case becomes clearer. What you prefer.
qcount = tab.count().py() | ||
pcount = df.count() | ||
|
||
assert int(qcount["k1"]) == int(pcount["k1"]) |
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.
Again, why not checking the output for both columns k1
and k2
?
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.
k2 is not numeric. In this case we could try to test the two objects. But count is a series object (a column table) and the translation does not seem direct to pykx
pcount = df.count() | ||
|
||
assert int(qcount["k1"]) == int(pcount["k1"]) | ||
assert int(qcount["k2"]) == 3 |
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.
Similar to a previous comment, is this really adding value to the test?
@@ -2029,3 +2029,136 @@ def test_keyed_loc_fixes(q): | |||
mkt[['k1', 'y']] | |||
with pytest.raises(KeyError): | |||
mkt['k1'] | |||
|
|||
|
|||
def test_pandas_count(q): |
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.
We should supply a case where the numeric_only
flag is enabled.
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.
There is a case where numeric_only is added
assert np.isnan(p_m[c]) == np.isnan(q_m[c].py()) | ||
|
||
q['tab'] = kx.toq(df) | ||
tab = q('1!`idx xcols update idx: til count tab from tab') |
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.
tab = q('1!`idx xcols update idx: til count tab from tab') | |
tab = q('`idx xkey update idx:i from tab') |
Addition of sensible default
Feature
What does this change introduce?
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