genfromtxt won't unpack if dtype=None
See original GitHub issueNot sure if this is a bug or a feature but if I use:
f_data = np.genfromtxt('file.dat', dtype=None, unpack=True)
where file.dat
is a standard data file with several columns (ie: http://pastebin.com/ihEW2dxS) the result is not transposed as one would expect having set unpack=True
.
For example, the line f_data = np.loadtxt('file.dat', unpack=True)
works as expected.
Issue Analytics
- State:
- Created 10 years ago
- Reactions:3
- Comments:6 (3 by maintainers)
Top Results From Across the Web
numpy.genfromtxt is not unpacking - Stack Overflow
The issue is that when the data is loaded it is a shape of (N,). dtype=None is in place so that the data...
Read more >numpy.genfromtxt — NumPy v1.23 Manual
If True, the returned array is transposed, so that arguments may be unpacked using x, y, z = genfromtxt(...) . When used with...
Read more >Importing data with genfromtxt — NumPy v1.9 Manual
Once the file is defined and open for reading, genfromtxt splits each non-empty line into a sequence of strings. Empty or commented lines...
Read more >numpy.genfromtxt — NumPy v1.9 Manual
For example, usecols = (1, 4, 5) will extract the 2nd, 5th and 6th columns. names : {None, True, str, sequence}, optional. If...
Read more >NumPy Input and Output: genfromtxt() function - w3resource
unpack, If True, the returned array is transposed, ... needed for StringIO example only >>> data1 = np.genfromtxt(str, dtype=None, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I also experience this.
loadtxt
is a bit more clever:Why doesn’t
genfromtxt
do this?The suggestion @moi90 made a couple years ago is correct.
genfromtxt
should do the same thing asloadtxt
.I think it will be easy to fix, so I’ve tagged the issue as a “good first issue”.