summaryrefslogtreecommitdiff
path: root/doc/release
diff options
context:
space:
mode:
authorAndrew Eckart <andrew.g.eckart@gmail.com>2020-09-11 11:31:03 -0500
committerGitHub <noreply@github.com>2020-09-11 09:31:03 -0700
commit3329d26c5d1d53f7fca1dfe253fdc43e93f0f6aa (patch)
tree9ddb298c4578ca268ae52a755c1dac1f99391333 /doc/release
parent02798e4ce39ae7882b19a3fde209472b7411d48a (diff)
downloadnumpy-3329d26c5d1d53f7fca1dfe253fdc43e93f0f6aa.tar.gz
ENH: Allow genfromtxt to unpack structured arrays (#16650)
* ENH: Allow genfromtxt to unpack structured arrays genfromtxt failed to transpose output when unpack=True and `dtype` was structured (or None). This patch resolves the issue by returning a list of arrays, as in `loadtxt`. Co-authored-by: Matti Picus <matti.picus@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net> Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
Diffstat (limited to 'doc/release')
-rw-r--r--doc/release/upcoming_changes/16650.compatibility.rst16
1 files changed, 16 insertions, 0 deletions
diff --git a/doc/release/upcoming_changes/16650.compatibility.rst b/doc/release/upcoming_changes/16650.compatibility.rst
new file mode 100644
index 000000000..653232355
--- /dev/null
+++ b/doc/release/upcoming_changes/16650.compatibility.rst
@@ -0,0 +1,16 @@
+`numpy.genfromtxt` now correctly unpacks structured arrays
+----------------------------------------------------------
+Previously, `numpy.genfromtxt` failed to unpack if it was called with
+``unpack=True`` and a structured datatype was passed to the ``dtype`` argument
+(or ``dtype=None`` was passed and a structured datatype was inferred).
+For example::
+
+ >>> data = StringIO("21 58.0\n35 72.0")
+ >>> np.genfromtxt(data, dtype=None, unpack=True)
+ array([(21, 58.), (35, 72.)], dtype=[('f0', '<i8'), ('f1', '<f8')])
+
+Structured arrays will now correctly unpack into a list of arrays,
+one for each column::
+
+ >>> np.genfromtxt(data, dtype=None, unpack=True)
+ [array([21, 35]), array([58., 72.])]