Mercurial > repos > iuc > table_compute
comparison scripts/table_compute.py @ 5:3bf5661c0280 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/table_compute commit f0fd699a4e713c57ab7d3d9d8cbb18b41aa6c7cd
| author | iuc |
|---|---|
| date | Mon, 14 Nov 2022 10:54:20 +0000 |
| parents | 93a3ce78ce55 |
| children |
comparison
equal
deleted
inserted
replaced
| 4:93a3ce78ce55 | 5:3bf5661c0280 |
|---|---|
| 55 # Fix whitespace issues in index or column names | 55 # Fix whitespace issues in index or column names |
| 56 data.columns = [col.strip() if type(col) is str else col | 56 data.columns = [col.strip() if type(col) is str else col |
| 57 for col in data.columns] | 57 for col in data.columns] |
| 58 data.index = [row.strip() if type(row) is str else row | 58 data.index = [row.strip() if type(row) is str else row |
| 59 for row in data.index] | 59 for row in data.index] |
| 60 return(data) | 60 return data |
| 61 | 61 |
| 62 @staticmethod | 62 @staticmethod |
| 63 def rangemaker(tab): | 63 def rangemaker(tab): |
| 64 # e.g. "1:3,2:-2" specifies "1,2,3,2,1,0,-1,-2" to give [0,1,2,1,0,-1,-2] | 64 # e.g. "1:3,2:-2" specifies "1,2,3,2,1,0,-1,-2" to give [0,1,2,1,0,-1,-2] |
| 65 # Positive indices are decremented by 1 to reference 0-base numbering | 65 # Positive indices are decremented by 1 to reference 0-base numbering |
| 104 out.extend(range(left - 1, right - 1, -1)) | 104 out.extend(range(left - 1, right - 1, -1)) |
| 105 else: | 105 else: |
| 106 err_mess = "%s should not be equal or contain a zero" % nums | 106 err_mess = "%s should not be equal or contain a zero" % nums |
| 107 if err_mess: | 107 if err_mess: |
| 108 print(err_mess) | 108 print(err_mess) |
| 109 return(None) | 109 return None |
| 110 return(out) | 110 return out |
| 111 | 111 |
| 112 | 112 |
| 113 # Set decimal precision | 113 # Set decimal precision |
| 114 pd.options.display.precision = uc.Default["precision"] | 114 pd.options.display.precision = uc.Default["precision"] |
| 115 | 115 |
| 316 pivot_index = params["PIVOT"]["pivot_index"] | 316 pivot_index = params["PIVOT"]["pivot_index"] |
| 317 pivot_column = params["PIVOT"]["pivot_columns"] | 317 pivot_column = params["PIVOT"]["pivot_columns"] |
| 318 pivot_values = params["PIVOT"]["pivot_values"] | 318 pivot_values = params["PIVOT"]["pivot_values"] |
| 319 pivot_aggfunc = params["PIVOT"]["pivot_aggfunc"] | 319 pivot_aggfunc = params["PIVOT"]["pivot_aggfunc"] |
| 320 | 320 |
| 321 if not(pivot_aggfunc): | 321 if not pivot_aggfunc: |
| 322 out_table = data.pivot( | 322 out_table = data.pivot( |
| 323 index=pivot_index, columns=pivot_column, values=pivot_values | 323 index=pivot_index, columns=pivot_column, values=pivot_values |
| 324 ) | 324 ) |
| 325 else: | 325 else: |
| 326 out_table = data.pivot_table( | 326 out_table = data.pivot_table( |
