### Navigation

- index
- modules |
- next |
- previous |
- NumPy v1.3 Manual (DRAFT) »
- NumPy Reference »
- Routines »
- Array creation routines »

# numpy.ones_like

`numpy.``ones_like`(x[, out])

  Returns an array of ones with the same shape and type as a given array.

  Equivalent to `a.copy().fill(1)`.

  Please refer to the documentation for zeros_like.

  See also

  `zeros_like`

  Examples

      >>> a = np.array([[1, 2, 3], [4, 5, 6]])
      >>> np.ones_like(a)
      array([[1, 1, 1],
             [1, 1, 1]])

### Navigation

- index
- modules |
- next |
- previous |
- NumPy v1.3 Manual (DRAFT) »
- NumPy Reference »
- Routines »
- Array creation routines »