### Navigation

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

# numpy.diagflat

`numpy.``diagflat`(v, k=0)

  Create a 2-dimensional array with the flattened input as a diagonal.

  Parameters: | v : array_like Input data, which is flattened and set as the k-th diagonal of the output. k : int, optional Diagonal to set. The default is 0.

  Examples

      >>> np.diagflat([[1,2],[3,4]])
      array([[1, 0, 0, 0],
             [0, 2, 0, 0],
             [0, 0, 3, 0],
             [0, 0, 0, 4]])

      >>> np.diagflat([1,2], 1)
      array([[0, 1, 0],
             [0, 0, 2],
             [0, 0, 0]])

### Navigation

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