I need some assistance with this Python problem.
I have a table called Matrix -
Matrix = [[['23'],['47'],['35'],['-']],
[['45'],['22'],['34'],['-']],
[['11'],['43'],['22'],['-']]]
What I would like to do is -
Remove/Delete an entire column IF all of it's cell values contain a null value like "-".
I already have a function which deletes an entire COLUMN by its index, but before I can do that I need to find a way of knowing if every cell in that particular column contain "-" before I can delete it.
Locating "-" -
for i, row in enumerate(Matrix):
for x, col in enumerate(row):
print Matrix[i][x], i, x
Output -
['23'] 0 0
['47'] 0 1
['35'] 0 2
['-'] 0 3
['45'] 1 0
['22'] 1 1
['34'] 1 2
['-'] 1 3
['11'] 2 0
['43'] 2 1
['22'] 2 2
['-'] 2 3
from this I can see that "-" does exist in each cell within column 3.
my attempt -
for i, row in enumerate(Matrix):
for x, col in enumerate(row):
if "-" in col:
print "Column to Delete is", x
p.s. I know I would have to do this in reverse, but I'm more interested in the logic of this.