Skip to content
Snippets Groups Projects
04_numpy.ipynb 29.2 KiB
Newer Older
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "r = np.random.randint(1, 10, 3)\n",
    "\n",
    "print('r is a row:                                  ', r)\n",
    "print('r.T should be a column:                      ', r.T, ' ... huh?')\n",
    "print('Ok, make n a 2D array with one row:          ', r.reshape(1, -1))\n",
    "print('We could also use the np.atleast_2d function:', np.atleast_2d(r))\n",
    "print('Now we can transpose r to get a column:')\n",
    "print(np.atleast_2d(r).T)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> Here we used a handy feature of the `reshape` method - if you pass `-1` for\n",
    "> the size of one dimension, it will automatically determine the size to use\n",
    "> for that dimension."
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}