a
:"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[1.2, 2.1, 3. ],\n",
" [2.3, 4.6, 5.9],\n",
" [3.2, 6.1, 9.1]])"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a.T"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"t, x, y = a.T"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([1.2, 2.1, 3. ])"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"t"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"or `loadtxt` can get the columns of the data file directly:u"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"t, x, y = np.loadtxt(\"test1.dat\", unpack=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Reading a comma delimited, or comma separated value (CSV) data file\n",
"\n",
"Here's a copy of `test2.csv`\n",
"\n",
"`# This line is a comment`Software | Version |
---|---|
Python | 3.7.7 64bit [GCC 7.3.0] |
IPython | 7.16.1 |
OS | Linux 3.10.0 1062.9.1.el7.x86_64 x86_64 with centos 7.7.1908 Core |
numpy | 1.18.5 |
matplotlib | 3.3.0 |
Fri Aug 07 15:11:32 2020 EDT |