df
>>> import numpy as np
>>>
>>>
>>> def noZeros(a):
... arr = np.array(a)
... rows = arr[ ~np.all(arr == 0, axis = 1)]
... colsTrue = ~np.all(rows == 0, axis = 0)
... return rows[:, colsTrue == True]
...
>>> a = [
... [0,'a',0,1,0],
... [0,0,'s',3,0],
... [0,0,3,1,0],
... [0,0,0,0,0],
... ]
>>> noZeros(a)
__main__:3: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in noZeros
File "/home/w2/env/lib/python3.4/site-packages/numpy/core/fromnumeric.py", line 2050, in all
return arr.all(axis=axis, out=out, **kwargs)
File "/home/w2/env/lib/python3.4/site-packages/numpy/core/_methods.py", line 41, in _all
return umr_all(a, axis, dtype, out, keepdims)
numpy.core._internal.AxisError: axis 1 is out of bounds for array of dimension 0