I'm trying to create a new list of data from some existing data. Currently though I am having the problem where each element of my new list is being saved as its own single-element list. I can't see why this is. My code is currently something like:
old_data = np.reshape(old_data, (49210, 1)) #Reshape into 1D array
new_data = [None] #Create empty list to be filled
max_value = np.nanmax(old_data)
threshold = 0.75 * max_value #Create threshold to be used as condition for new list.
for x in range(len(old_data)):
if old_data[x] > threshold:
new_data.append(old_data[x])
Please note that old_data
was stored as a 2D array, which is why I have included that np.reshape
command at the start.
As I said above, each time the condition is fulfilled the value is stored as a new element in new_data
, but the element is an array of type float32 with size (1,). So new_data
has ended up being an array of arrays. I'm not sure why this is. I would really just like a regular array/list output from this so that new_data is tractable. Any advice is appreciated.