I'm using the numpy.delete function to remove elements from several arrays. I started from this question Make this simple for/if block more pythonic and arrived, after applying the answer given there, to this:
# Data lists.
a = [3,4,5,12,6,8,78,5,6]
b = [6,4,1.,2,8,784.,43,6.,2]
c = [8,4.,32.,6,1,7,2.,9,23]
# Maximum limit.
max_limit = 20.
# Store indexes of elements to be removed.
indexes = [i for i, t in enumerate(zip(b, c)) if any(e > max_limit for e in t)]
# Remove elements from all lists.
big_array = np.array([a, b, c])
clean_array = np.delete(big_array, indexes, axis=1)
# Final clean lists.
a_clean, b_clean, c_clean = clean_array
The issue I'm having is that one of my lists is actually made of strings rather than floats, like this:
# Data lists.
a = ['a','b','c','d','e','f','g','h','i'] # <-- strings
b = [6,4,1.,2,8,784.,43,6.,2] # <-- floats
c = [8,4.,32.,6,1,7,2.,9,23] # <-- floats
and when I apply the code above the numpy.delete line converts all elements in all final lists (a_clean, b_clean, c_clean) to strings rather than preserving only the first one as strings and the rest as floats.
How can I prevent this from happening or fix it if it can't be helped?