Skip to content

Commit 3405543

Browse files
authored
Tab2df update and test fix (#78)
* wording update * updated ksdistrib to correspond with scipy * sanity check for scipy version within select.q added * updated tab2df to account for list of char being passed * updated percentage_recurring_all_val to account for pandas update
1 parent 5ff9415 commit 3405543

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

fresh/tests/test.p

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ p)def< percentage_recurring_all_val(x):
5252
x = pd.Series(x)
5353
if len(x) == 0:
5454
return np.nan
55+
x = x.copy()
5556
value_counts = x.value_counts()
5657
return value_counts[value_counts > 1].sum() / len(x)
5758

util/tests/utiltst.t

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ df :.ml.tab2df tt:([]fcol:12?1.;jcol:12?100;scol:12?`aaa`bbb`ccc)
2424
dfj:.ml.tab2df tj:select by jcol from tt
2525
dfs:.ml.tab2df ts:select by scol from tt
2626
dfsj:.ml.tab2df tx:select by scol,jcol from tt
27+
dfc:.ml.tab2df ([]s:`a`b`c;j:1 2 3;c:"ABC")
2728
(dfsx:.ml.tab2df tx)[`:index][:;`:names;(`scol;::)]
2829
(dfxj:.ml.tab2df tx)[`:index][:;`:names;(::;`jcol)]
2930
(dfxx:.ml.tab2df tx)[`:index][:;`:names;(::;::)]
3031
tt2:([]date:2005.07.14 2005.07.15;timesp:("N"$"12:10:30.000500000";"N"$"12:13:30.000200007");time:20:30:00.001 19:23:20.201;str:enlist each ("h";"i");ind:1.3 2.5;bool:10b)
3132
112 112 112 10 -9 -1h~type each first (.ml.tab2df tt2)[`:values]`
33+
(dfc[`:c.values]`)~enlist each "ABC"
3234

3335
.ml.shape[1 2 3*/:til 10] ~ np[`:shape][1 2 3*/:til 10]`
3436
.ml.shape[enlist 1] ~ np[`:shape][enlist 1]`

util/util.q

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ traintestsplit:{[x;y;sz]`xtrain`ytrain`xtest`ytest!raze(x;y)@\:/:(0,floor n*1-sz
2020
i.q2npdt:{.p.import[`numpy;`:array;("p"$@[4#+["d"$0];-16+type x]x)-"p"$1970.01m;"datetime64[ns]"]`.}
2121
/ q tab to pandas dataframe
2222
tab2df:{
23-
r:.p.import[`pandas;`:DataFrame;@[flip 0!x;i.fndcols[x]"pmdznuvt";i.q2npdt]][@;cols x];
23+
updx:@[flip 0!x;i.fndcols[x;"c"];enlist each];
24+
r:.p.import[`pandas;`:DataFrame;@[updx;i.fndcols[x]"pmdznuvt";i.q2npdt]][@;cols x];
2425
$[count k:keys x;r[`:set_index]k;r]}
2526
/ pandas dataframe to q tab
2627
df2tab_tz:{

0 commit comments

Comments
 (0)