Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.

Evert-Jan van Dijk
Evert-Jan van Dijk
1,381 Points

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.

Evert-Jan van Dijk
Evert-Jan van Dijk
1,381 Points

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