0

I need to create an empty nd-array in python without zeros or ones functions looks like in c++ with this command for array 3*4 for integers:

int x[3][4]

Please help me

7
  • 2
    Why do you say 'without zeros or ones'? Commented Nov 4, 2019 at 19:49
  • 1
    What do you mean by "empty"? In numpy, usually empty means "one or more of the dimensions has extent 0". If you really mean it should have dimensions 3x4, then zeros or ones is the way to go. It would be unusual in numpy to allocate an array without initializing the content—but as I have just this second learned from matt's comment, there is a function empty that will do it. Commented Nov 4, 2019 at 19:50
  • 1
    docs.scipy.org/doc/numpy/reference/generated/… Commented Nov 4, 2019 at 19:51
  • 1
    Both of those reasons are somewhat incorrect. If 0 is important, than you don't want an array of random values. Even c++ will initialize arrays depending on compiler options. So if you have a special value you should initialize the array to a set of valid values. Also, changing the type seems irrelevant to whether or not it was initialized. Commented Nov 4, 2019 at 19:56
  • 1
    If you don't like empty(), try full(). That lets you specify the initial value. Commented Nov 4, 2019 at 19:57

1 Answer 1

2

Numpy has a function for that. empty

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.