Skip to content
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 isin #30

Merged
merged 15 commits into from
Jan 22, 2024
18 changes: 16 additions & 2 deletions src/pykx/pandas_api/pandas_meta.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from . import api_return
from ..exceptions import QError


def _init(_q):
global q
q = _q
Expand Down Expand Up @@ -209,7 +208,22 @@ def abs(self, numeric_only=False):
if numeric_only:
tab = _get_numeric_only_subtable(self)
return q.abs(tab)


@api_return
def isin(self, values):
tab = self
dic_value = kx.q("{$[98h = type x; flip x; x]}", values)
return q("{flip x! {"
"tipo: abs[type z[x][0]];"
"y: $[99h = type y; y[x]; y];"
marcosvm13 marked this conversation as resolved.
Show resolved Hide resolved
"y: y[where tipo = abs type each y];"
marcosvm13 marked this conversation as resolved.
Show resolved Hide resolved
marcosvm13 marked this conversation as resolved.
Show resolved Hide resolved
"$[count[y] = 0; "
"count[z[x]]#0b;"
marcosvm13 marked this conversation as resolved.
Show resolved Hide resolved
"(|/) $[tipo = 10; "
marcosvm13 marked this conversation as resolved.
Show resolved Hide resolved
"y"+"~"+"/:\:z[x];"
"y"+"="+"\:z[x]]]}[;z;y]"
"each x}", tab.columns, tab, dic_value)

@convert_result
def all(self, axis=0, bool_only=False, skipna=True):
res, cols = preparse_computations(self, axis, skipna, bool_only=bool_only)
Expand Down