# HG changeset patch
# User iuc
# Date 1618933570 0
# Node ID 93a3ce78ce557a283bbb223fcb8f043281283759
# Parent 60ff16842fcd043c9525bb229b82a787a66c21a5
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/table_compute commit d741508e5ed912cdeee4f67ec8451b6e6865363c"
diff -r 60ff16842fcd -r 93a3ce78ce55 allowed_functions.xml
--- a/allowed_functions.xml Fri Oct 18 06:22:51 2019 -0400
+++ b/allowed_functions.xml Tue Apr 20 15:46:10 2021 +0000
@@ -5,7 +5,7 @@
This file is parsed by the python scripts to reduce
duplicate definitions of allowed functions -->
-
+
diff -r 60ff16842fcd -r 93a3ce78ce55 scripts/table_compute.py
--- a/scripts/table_compute.py Fri Oct 18 06:22:51 2019 -0400
+++ b/scripts/table_compute.py Tue Apr 20 15:46:10 2021 +0000
@@ -314,12 +314,20 @@
out_table = pd.melt(data, id_vars=melt_ids, value_vars=melt_values)
elif general_mode == "pivot":
pivot_index = params["PIVOT"]["pivot_index"]
- pivot_column = params["PIVOT"]["pivot_column"]
+ pivot_column = params["PIVOT"]["pivot_columns"]
pivot_values = params["PIVOT"]["pivot_values"]
+ pivot_aggfunc = params["PIVOT"]["pivot_aggfunc"]
- out_table = data.pivot(
- index=pivot_index, columns=pivot_column, values=pivot_values
- )
+ if not(pivot_aggfunc):
+ out_table = data.pivot(
+ index=pivot_index, columns=pivot_column, values=pivot_values
+ )
+ else:
+ out_table = data.pivot_table(
+ index=pivot_index, columns=pivot_column, values=pivot_values,
+ aggfunc=pivot_aggfunc
+ )
+
elif general_mode == "custom":
custom_func = params["fulltable_customop"]
diff -r 60ff16842fcd -r 93a3ce78ce55 table_compute.xml
--- a/table_compute.xml Fri Oct 18 06:22:51 2019 -0400
+++ b/table_compute.xml Tue Apr 20 15:46:10 2021 +0000
@@ -1,7 +1,8 @@
-
+computes operations on table data
- 0.9.2
+ 1.2.4
+ 0]]>]]>allowed_functions.xml
@@ -92,8 +93,8 @@
- pandas
- numpy
+ pandas
+ numpy
+ label="Index"
+ help="Name of the column to use as new index" >
+ label="Column"
+ help="Name of the column to use to generate the columns of the new table from.
+ Cannot be used in conjunction with the Column-Function Mapping parameter."
+ optional="true">
+ label="Values"
+ help="Names of the columns to use for populating the cells of the new table. Leave blank to use all." >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ label="Custom expression on 'table', along 'axis' (0 or 1)"
+ help="The parameter name is @COPEN@table@CCLOSE@ and @COPEN@axis@CCLOSE@, referring to the table being acted on and the column (@COPEN@0@CCLOSE@) or row (@COPEN@1@CCLOSE@) to perform the operation on. Numpy, math, Pandas DataFrame operators, and inline @COPEN@if else@CCLOSE@ are supported (e.g. @COPEN@np.log(table) - table.mean(0) / table.std(1)@CCLOSE@). See Example #5 in the Help section. ">
@@ -1295,6 +1365,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 60ff16842fcd -r 93a3ce78ce55 test-data/pivot.tsv
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/pivot.tsv Tue Apr 20 15:46:10 2021 +0000
@@ -0,0 +1,7 @@
+ Name Position City Age Random
+0 Mary Manager Boston 34 0.678577
+1 Josh Programmer New York 37 0.973168
+2 Jon Manager Chicago 29 0.146668
+3 Lucy Manager Los Angeles 40 0.150120
+4 Jane Programmer Chicago 29 0.112769
+5 Sue Programmer Boston 31 0.185198
\ No newline at end of file
diff -r 60ff16842fcd -r 93a3ce78ce55 test-data/table1.tsv
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/table1.tsv Tue Apr 20 15:46:10 2021 +0000
@@ -0,0 +1,10 @@
+A B C D E
+foo one small 1 2
+foo one large 2 4
+foo one large 2 5
+foo two small 3 5
+foo two small 3 6
+bar one large 4 6
+bar one small 5 8
+bar two small 6 9
+bar two large 7 9