Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Introduction to NumPy Array Organization Indexing

VisibleDeprecationWarning?

I am getting this warning when I try to create the new study_minutes array:

<ipython-input-81-f1dabc6571fc>:1: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray study_minutes = np.array([

I used the same code as presented in the video but it's not creating the same shaped array (2, 100)

Code: study_minutes = np.array([ study_minutes, np.zeros(100, np.uint16) ])

2 Answers

Megan Amendola
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree seal-36
Megan Amendola
Treehouse Teacher

This comes from an update to NumPy. It wants you to now input it as: study_minutes = np.array([ study_minutes, np.zeros(100, np.uint16)], dtype=object)

Which version of NumPy are you using at the moment? You can run print(np.__version__) inside of your Jupyter Notebook to see.

I am on version 1.19.2. Adding dtype=object does remove the error message, however leaves some awkward bugs. When running study_minutes.shape it returns (2,) and study_minutes returns a couple of nested tuples of arrays or whatever:

array([array([array([array([array([array([array([array([[150,  60,  80,  60,  30,  90,   0,   0,   0,   0,   0,   0,   0,
          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
          0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
          0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  #etcetera

Do you know of any solutions to this problem? Please tell me.

Never mind it's already been solved, I had forgotten to run all the previous code, since I started a new session.