numpy / numpy/numpy

genfromtxt does not generate multidimensional array when data has only one column.

Open
#11,498 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
32.8k
Forks
12.8k
Avg merge
1d 7h
Merged PRs (30d)
197

Description

Environment
  • numpy 1.14.4
  • Python 2.7.11
Overview

genfromtxt does not generate multidimensional array when data has only one column.

>>> import numpy as np
>>> from StringIO import StringIO
>>> data = "1, 2, 3\n4, 5, 6"
>>> np.genfromtxt(StringIO(data), delimiter=",")
array([[1., 2., 3.],
       [4., 5., 6.]])
>>> data = "1\n2"
>>> np.genfromtxt(StringIO(data), delimiter=",") # I expect array([[1.], [2.,]]) but the result is array([1., 2.])
array([1., 2.])
>>> np.genfromtxt(StringIO(data), delimiter="\n")
array([1., 2.])

Is this expected action?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the two single-column examples using the genfromtxt entry point and compare them with the multi-column case. Determine the intended array shape for one-column input, then add or update regression coverage so the behavior is explicit and verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.