search
Search
Unlock 100+ guides
search toc
close
Cancel
Post
account_circle
Profile
exit_to_app
Sign out
What does this mean?
Why is this true?
Give me some examples!
search
keyboard_voice
close
Searching Tips
Search for a recipe:
"Creating a table in MySQL"
Search for an API documentation: "@append"
Search for code: "!dataframe"
Apply a tag filter: "#python"
Useful Shortcuts
/ to open search panel
Esc to close search panel
to navigate between search results
d to clear all current filters
Enter to expand content preview
Doc Search
Code Search Beta
SORRY NOTHING FOUND!
mic
Start speaking...
Voice search is only supported in Safari and Chrome.
Shrink
Navigate to

# NumPy | full method

schedule Aug 12, 2023
Last updated
local_offer
PythonNumPy
Tags
expand_more
mode_heat
Master the mathematics behind data science with 100+ top-tier guides
Start your free 7-days trial now!

Numpy's `full(~)` method creates a new Numpy array whose entries are filled by the specified value.

# Parameters

1. `shape` | `int` or `sequence<int>`

The dimensions of the resulting array.

2. `fill_value` | `scalar`

The value to fill the entires.

3. `dtype` | `string` or `type` | `optional`

The desired data type for the resulting array. By default, the type is inferred from the `fill_value`.

# Return value

A Numpy array whose entries are filled by the specified value.

# Examples

## One-dimensional arrays

To create a 1D Numpy array of size 5, with the value 2 as the entries:

``` np.full(5, 2) array([2, 2, 2, 2, 2]) ```

Here, the data-type is inferred as `int64`:

``` np.full(5, 2).dtype dtype('int64') ```

## Two-dimensional arrays

To create a 2D Numpy array with 2 rows and 3 columns, with the value 5 as the entries:

``` np.full((2,3), 5) array([[5, 5, 5], [5, 5, 5]]) ```
Edited by 0 others
thumb_up
thumb_down
Comment
Citation
Ask a question or leave a feedback...
thumb_up
0
thumb_down
0
chat_bubble_outline
0
settings
Enjoy our search
Hit / to insta-search docs and recipes!