Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e1961a4

Browse files
author
craigsdennis
committed
Explores ufuncs and broadcasting
1 parent 902886a commit e1961a4

File tree

1 file changed

+209
-0
lines changed

1 file changed

+209
-0
lines changed

‎Introduction to NumPy.ipynb

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,6 +1555,215 @@
15551555
"orders.dot(prices)"
15561556
]
15571557
},
1558+
{
1559+
"cell_type": "code",
1560+
"execution_count": 74,
1561+
"metadata": {},
1562+
"outputs": [
1563+
{
1564+
"data": {
1565+
"text/plain": [
1566+
"(array([1, 2, 3, 4, 5]), array([ 6, 7, 8, 9, 10]))"
1567+
]
1568+
},
1569+
"execution_count": 74,
1570+
"metadata": {},
1571+
"output_type": "execute_result"
1572+
}
1573+
],
1574+
"source": [
1575+
"a, b = np.split(np.arange(1, 11), 2)\n",
1576+
"a, b"
1577+
]
1578+
},
1579+
{
1580+
"cell_type": "code",
1581+
"execution_count": 75,
1582+
"metadata": {},
1583+
"outputs": [
1584+
{
1585+
"data": {
1586+
"text/plain": [
1587+
"array([ 7, 9, 11, 13, 15])"
1588+
]
1589+
},
1590+
"execution_count": 75,
1591+
"metadata": {},
1592+
"output_type": "execute_result"
1593+
}
1594+
],
1595+
"source": [
1596+
"a + b"
1597+
]
1598+
},
1599+
{
1600+
"cell_type": "code",
1601+
"execution_count": 76,
1602+
"metadata": {},
1603+
"outputs": [
1604+
{
1605+
"data": {
1606+
"text/plain": [
1607+
"array([-5, -5, -5, -5, -5])"
1608+
]
1609+
},
1610+
"execution_count": 76,
1611+
"metadata": {},
1612+
"output_type": "execute_result"
1613+
}
1614+
],
1615+
"source": [
1616+
"a - b"
1617+
]
1618+
},
1619+
{
1620+
"cell_type": "code",
1621+
"execution_count": 77,
1622+
"metadata": {},
1623+
"outputs": [
1624+
{
1625+
"data": {
1626+
"text/plain": [
1627+
"array([5, 5, 5, 5, 5])"
1628+
]
1629+
},
1630+
"execution_count": 77,
1631+
"metadata": {},
1632+
"output_type": "execute_result"
1633+
}
1634+
],
1635+
"source": [
1636+
"b - a"
1637+
]
1638+
},
1639+
{
1640+
"cell_type": "code",
1641+
"execution_count": 78,
1642+
"metadata": {},
1643+
"outputs": [
1644+
{
1645+
"data": {
1646+
"text/plain": [
1647+
"array([ 6, 14, 24, 36, 50])"
1648+
]
1649+
},
1650+
"execution_count": 78,
1651+
"metadata": {},
1652+
"output_type": "execute_result"
1653+
}
1654+
],
1655+
"source": [
1656+
"a * b"
1657+
]
1658+
},
1659+
{
1660+
"cell_type": "code",
1661+
"execution_count": 79,
1662+
"metadata": {},
1663+
"outputs": [
1664+
{
1665+
"data": {
1666+
"text/plain": [
1667+
"array([3, 4, 5, 6, 7])"
1668+
]
1669+
},
1670+
"execution_count": 79,
1671+
"metadata": {},
1672+
"output_type": "execute_result"
1673+
}
1674+
],
1675+
"source": [
1676+
"a + 2"
1677+
]
1678+
},
1679+
{
1680+
"cell_type": "code",
1681+
"execution_count": 81,
1682+
"metadata": {},
1683+
"outputs": [
1684+
{
1685+
"data": {
1686+
"text/plain": [
1687+
"array([3, 4, 5, 6, 7])"
1688+
]
1689+
},
1690+
"execution_count": 81,
1691+
"metadata": {},
1692+
"output_type": "execute_result"
1693+
}
1694+
],
1695+
"source": [
1696+
"a + np.repeat(2, 5)"
1697+
]
1698+
},
1699+
{
1700+
"cell_type": "code",
1701+
"execution_count": 82,
1702+
"metadata": {},
1703+
"outputs": [
1704+
{
1705+
"data": {
1706+
"text/plain": [
1707+
"(array([[0., 1., 2.],\n",
1708+
" [3., 4., 5.],\n",
1709+
" [6., 7., 8.]]), array([0., 1., 2.]))"
1710+
]
1711+
},
1712+
"execution_count": 82,
1713+
"metadata": {},
1714+
"output_type": "execute_result"
1715+
}
1716+
],
1717+
"source": [
1718+
">>> x1 = np.arange(9.0).reshape((3, 3))\n",
1719+
">>> x2 = np.arange(3.0)\n",
1720+
"x1, x2"
1721+
]
1722+
},
1723+
{
1724+
"cell_type": "code",
1725+
"execution_count": 83,
1726+
"metadata": {},
1727+
"outputs": [
1728+
{
1729+
"data": {
1730+
"text/plain": [
1731+
"array([[ 0., 2., 4.],\n",
1732+
" [ 3., 5., 7.],\n",
1733+
" [ 6., 8., 10.]])"
1734+
]
1735+
},
1736+
"execution_count": 83,
1737+
"metadata": {},
1738+
"output_type": "execute_result"
1739+
}
1740+
],
1741+
"source": [
1742+
">>> np.add(x1, x2)"
1743+
]
1744+
},
1745+
{
1746+
"cell_type": "code",
1747+
"execution_count": 84,
1748+
"metadata": {},
1749+
"outputs": [
1750+
{
1751+
"data": {
1752+
"text/plain": [
1753+
"array([[ 2., 3., 4.],\n",
1754+
" [ 5., 6., 7.],\n",
1755+
" [ 8., 9., 10.]])"
1756+
]
1757+
},
1758+
"execution_count": 84,
1759+
"metadata": {},
1760+
"output_type": "execute_result"
1761+
}
1762+
],
1763+
"source": [
1764+
"np.add(x1, 2)"
1765+
]
1766+
},
15581767
{
15591768
"cell_type": "code",
15601769
"execution_count": null,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /