Question: I want to make a simple one-dimensional array with numpy.

```
import numpy as np
arr = np.array()  # how do I initialize a float array?

np.append(arr, "3453.2")
np.append(arr, "1321.3")
np.append(arr, "2003.6")

```

I have tried `np.zeros()`, `np.ones()`, `np.empty()` and so on. But I can't find out how to initialize an empty array.

Answer: 
Array from list of floats:

```
arr = np.array([1., 2., 3.])

```

Empty array:

```
arr = np.empty(shape=())
print(arr.shape)  # ()

```

Empty 1d-array:

```
arr = np.empty(shape(1,))
print(arr.shape)  # (1,)

```

It's unclear what you really want.

Read [the docs about array-creation](https://docs.scipy.org/doc/numpy-1.12.0/user/basics.creation.html).

**Important remark**: don't overuse append and co. / don't resize array's often! This calls for bad performance because of copying of data! That's not how numpy-array should be used.

Build a list (where append is fast) and then build an array when the list is ready. Research append on lists vs. arrays for the reasons!

Like:

```
l = []
l.append(1.)
l.append(2.)
arr = np.array(l)

```
You shouldn't use empty arrays and `append` to them because each `numpy.append` is an `O(n)` operation making the array creation have `O(n**2)` performance. 

Pythons list would be better because they have (amortized) `O(1)` appends.

---

However if you really want an empty array, you could just use an empty list as input for `np.array`:

```
import numpy as np

arr = np.array([], dtype=float)   # dtype specifies the type of the elements

```

In case you meant an empty array to be an array having the correct size but not yet the correct values you should use `np.empty`:

```
arr = np.empty(shape=3, dtype=float)  # 3 element array
arr[0] = 3453.2
arr[1] = 1321.3
arr[2] = 2003.6

```