0

So, is there a way to achieve the same thing in python as the following line in R: matrix( rep(NA, 3*5), ncol = 5 )

To be more specific, do I need to define an array before reference it in python? How is this process different from MATLAB? I tried to create an array full of 0 using np.zeros((5, 3)), but is there a way to create an empty one and simply keep adding numbers into it?

1
  • This variable-initialization (or allocation) is something simpy not performed in python. The matrix full of zeros is as close to empty you will get. Also the exact same question exists here: stackoverflow.com/questions/13347559/… Commented Nov 30, 2016 at 17:49

1 Answer 1

1

An array full of 0 using np.zeros((5, 3)) is the best thing you can do here because, there no such thing as "variable declaration" or "variable initialization" in Python.

See this answer: Python variable declaration

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.