Skip to content

Commit 23bd785

Browse files
author
craigsdennis
committed
Adds reshaping and ravel examples
1 parent 477bccc commit 23bd785

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed

Introduction to NumPy.ipynb

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,107 @@
13741374
"practice.flags['OWNDATA'], not_copied.flags['OWNDATA']"
13751375
]
13761376
},
1377+
{
1378+
"cell_type": "code",
1379+
"execution_count": 80,
1380+
"metadata": {},
1381+
"outputs": [
1382+
{
1383+
"data": {
1384+
"text/plain": [
1385+
"(array([[90210, 1, 2, 3, 4, 5],\n",
1386+
" [ 6, 7, 8, 9, 10, 11],\n",
1387+
" [ 12, 13, 14, 15, 16, 17],\n",
1388+
" [ 18, 19, 20, 21, 22, 23],\n",
1389+
" [ 24, 25, 26, 27, 28, 29],\n",
1390+
" [ 30, 31, 32, 33, 34, 35],\n",
1391+
" [ 36, 37, 38, 39, 40, 41]]),\n",
1392+
" array([[90210, 1, 2, 3, 4, 5, 6, 7, 8,\n",
1393+
" 9, 10, 11, 12, 13],\n",
1394+
" [ 14, 15, 16, 17, 18, 19, 20, 21, 22,\n",
1395+
" 23, 24, 25, 26, 27],\n",
1396+
" [ 28, 29, 30, 31, 32, 33, 34, 35, 36,\n",
1397+
" 37, 38, 39, 40, 41]]),\n",
1398+
" True)"
1399+
]
1400+
},
1401+
"execution_count": 80,
1402+
"metadata": {},
1403+
"output_type": "execute_result"
1404+
}
1405+
],
1406+
"source": [
1407+
"practice_view = practice.reshape(3, 14)\n",
1408+
"practice, practice_view, practice_view.base is practice"
1409+
]
1410+
},
1411+
{
1412+
"cell_type": "code",
1413+
"execution_count": 82,
1414+
"metadata": {},
1415+
"outputs": [
1416+
{
1417+
"data": {
1418+
"text/plain": [
1419+
"(21, 2)"
1420+
]
1421+
},
1422+
"execution_count": 82,
1423+
"metadata": {},
1424+
"output_type": "execute_result"
1425+
}
1426+
],
1427+
"source": [
1428+
"practice.reshape(-1, 2).shape"
1429+
]
1430+
},
1431+
{
1432+
"cell_type": "code",
1433+
"execution_count": 83,
1434+
"metadata": {},
1435+
"outputs": [
1436+
{
1437+
"data": {
1438+
"text/plain": [
1439+
"array([90210, 1, 2, 3, 4, 5, 6, 7, 8,\n",
1440+
" 9, 10, 11, 12, 13, 14, 15, 16, 17,\n",
1441+
" 18, 19, 20, 21, 22, 23, 24, 25, 26,\n",
1442+
" 27, 28, 29, 30, 31, 32, 33, 34, 35,\n",
1443+
" 36, 37, 38, 39, 40, 41])"
1444+
]
1445+
},
1446+
"execution_count": 83,
1447+
"metadata": {},
1448+
"output_type": "execute_result"
1449+
}
1450+
],
1451+
"source": [
1452+
"practice.ravel()"
1453+
]
1454+
},
1455+
{
1456+
"cell_type": "code",
1457+
"execution_count": 85,
1458+
"metadata": {},
1459+
"outputs": [],
1460+
"source": [
1461+
"np.ravel?\n"
1462+
]
1463+
},
1464+
{
1465+
"cell_type": "code",
1466+
"execution_count": null,
1467+
"metadata": {},
1468+
"outputs": [],
1469+
"source": []
1470+
},
1471+
{
1472+
"cell_type": "code",
1473+
"execution_count": null,
1474+
"metadata": {},
1475+
"outputs": [],
1476+
"source": []
1477+
},
13771478
{
13781479
"cell_type": "code",
13791480
"execution_count": null,

0 commit comments

Comments
 (0)