FFFF ENH: Allow genfromtxt to unpack structured arrays by AndrewEckart · Pull Request #16650 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: Allow genfromtxt to unpack structured arrays #16650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Sep 11, 2020
Merged
Prev Previous commit
Next Next commit
Must specify dtype=None for automatic unpacking
  • Loading branch information
AndrewEckart committed Aug 3, 2020
commit f9e245cf73e2737d0043ff5f6cf1081b4eaf594f
5 changes: 3 additions & 2 deletions doc/release/upcoming_changes/16650.compatibility.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
`np.genfromtxt` now correctly unpacks structured arrays
-------------------------------------------------------------------------
Previously, `genfromtxt` failed to unpack if it was called with ``unpack=True``
and a structured datatype was inferred or passed to the ``dtype`` argument.
and a structured datatype was passed to the ``dtype`` argument
(or ``dtype=None`` was passed and a structured datatype was inferred).

Structured arrays will now correctly unpack into a list of arrays,
one for each column::

>>> np.genfromtxt(StringIO("21 58.0 \n 35 72.0"), unpack=True)
>>> np.genfromtxt(StringIO("21 58.0 \n 35 72.0"), dtype=None, unpack=True)
[array([21, 35]), array([58., 72.])]
0