nws_tools.
printdata
(data, leadrow, leadcol, fname=None)[source]¶Pretty-print/-save array-like data
Parameters: | data : NumPy 2darray
leadrow : Python list or NumPy 1darray
leadcol : Python list or NumPy 1darray
fname : str
|
---|---|
Returns: | Nothing : None |
See also
texttable
Notes
Uses the texttable module to print results
Examples
>>> import numpy as np
>>> data = np.random.rand(2,3)
>>> row1 = ["a","b",3]
>>> col1 = np.arange(2)
>>> printdata(data,row1,col1)
+--------------------+--------------------+--------------------+--------------------+
| | a | b | 3 |
+====================+====================+====================+====================+
| 0 | 0.994018537964 | 0.707532139166 | 0.767497407803 |
+--------------------+--------------------+--------------------+--------------------+
| 1 | 0.914193045048 | 0.758181936461 | 0.216752553325 |
+--------------------+--------------------+--------------------+--------------------+
>>> row1 = ["labels"] + row1
>>> printdata(data,row1,col1,fname='dummy')
+--------------------+--------------------+--------------------+--------------------+
| labels | a | b | 3 |
+====================+====================+====================+====================+
| 0 | 0.994018537964 | 0.707532139166 | 0.767497407803 |
+--------------------+--------------------+--------------------+--------------------+
| 1 | 0.914193045048 | 0.758181936461 | 0.216752553325 |
+--------------------+--------------------+--------------------+--------------------+
>>> cat dummy.csv
labels, a, b, 3
0,0.994018537964,0.707532139166,0.767497407803
1,0.914193045048,0.758181936461,0.216752553325