Attributeerror: 'numpy.ndarray' Object has no attribute 'pop'

Asked

Viewed 353 times

0

I am trying to run this code nhttps://colab.research.google.com and gives this error.

# Preprocessing function #n está funcionando :(
def preprocess(data, columns_to_ignore):
    # Sort by descending id and delete columns
    for id in sorted(columns_to_ignore, reverse=True):
        [r.pop(id) for r in data]
    for i in range(len(data)):
      # Converting 'sex' field to float (id is 1 after removing labels column)
      data[i][1] = 1. if data[i][1] == 'female' else 0.
    return np.array(data, dtype=np.float32)

# Ignore 'name' and 'ticket' columns (id 1 & 6 of data array)
to_ignore=[1, 6]

# Preprocess data
data = preprocess(data, to_ignore)
  • For documentation, the guy numpy.ndarray, in fact, it does not have the method pop(). Its object r should be this kind?

  • I’m not sure, I’m following this tutorial https://colab.research.google.com/drive/1D0HyGpI1M_Eqh_GR3KOG3k7Skr2gfxJO#scrollTo=mBkYXqvMQ29c, http://learntf.org/tutorials/quickstart.html

  • looks like the code was meant to work with lists of lists, and you’re passing a numpy.array...

  • It usually works here https://repl.it/@hedgtyhedgty/Titanic-NN

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.