You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
venv/PyCharm 2025.2.1.1/plugins/python-ce/helpers/testResources/data/docstrings/numpy_ZD846170.html

47 lines
1.3 KiB

<p>array(object, dtype=None, copy=True, order=None, subok=False, ndmin=0)</p>
<p>Create an array.</p>
<h4 class="heading">See Also</h4>
empty, empty_like, zeros, zeros_like, ones, ones_like, fill<h4 class="heading">Examples</h4>
<pre class="rst-doctest-block">
&gt;&gt;&gt; np.array([1, 2, 3])
array([1, 2, 3])
</pre>
<p>Upcasting:</p>
<pre class="rst-doctest-block">
&gt;&gt;&gt; np.array([1, 2, 3.0])
array([ 1., 2., 3.])
</pre>
<p>More than one dimension:</p>
<pre class="rst-doctest-block">
&gt;&gt;&gt; np.array([[1, 2], [3, 4]])
array([[1, 2],
[3, 4]])
</pre>
<p>Minimum dimensions 2:</p>
<pre class="rst-doctest-block">
&gt;&gt;&gt; np.array([1, 2, 3], ndmin=2)
array([[1, 2, 3]])
</pre>
<p>Type provided:</p>
<pre class="rst-doctest-block">
&gt;&gt;&gt; np.array([1, 2, 3], dtype=complex)
array([ 1.+0.j, 2.+0.j, 3.+0.j])
</pre>
<p>Data-type consisting of more than one element:</p>
<pre class="rst-doctest-block">
&gt;&gt;&gt; x = np.array([(1,2),(3,4)],dtype=[('a','&lt;i4'),('b','&lt;i4')])
&gt;&gt;&gt; x['a']
array([1, 3])
</pre>
<p>Creating an array from sub-classes:</p>
<pre class="rst-doctest-block">
&gt;&gt;&gt; np.array(np.mat('1 2; 3 4'))
array([[1, 2],
[3, 4]])
</pre>
<pre class="rst-doctest-block">
&gt;&gt;&gt; np.array(np.mat('1 2; 3 4'), subok=True)
matrix([[1, 2],
[3, 4]])
</pre>