[Numpy-discussion] loadtxt and usecols

Ralf Gommers ralf.gommers at gmail.com
Mon Nov 9 14:36:57 EST 2015

On Mon, Nov 9, 2015 at 7:42 PM, Benjamin Root <ben.v.root at gmail.com> wrote:

> My personal rule for flexible inputs like that is that it should be
> encouraged so long as it does not introduce ambiguity. Furthermore,
> Allowing a scalar as an input doesn't add a congitive disconnect on the
> user on how to specify multiple columns. Therefore, I'd give this a +1.
> On Mon, Nov 9, 2015 at 4:15 AM, Irvin Probst <
> irvin.probst at ensta-bretagne.fr> wrote:
>> Hi,
>> I've recently seen many students, coming from Matlab, struggling against
>> the usecols argument of loadtxt. Most of them tried something like:
>> loadtxt("foo.bar", usecols=2) or the ones with better documentation
>> reading skills tried loadtxt("foo.bar", usecols=(2)) but none of them
>> understood they had to write usecols=[2] or usecols=(2,).
>> Is there a policy in numpy stating that this kind of arguments must be
>> sequences ?
There isn't. In many/most cases it's array_like, which means scalar,
sequence or array.

> I think that being able to an int or a sequence when a single column is
>> needed would make this function a bit more user friendly for beginners. I
>> would gladly submit a PR if noone disagrees.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20151109/1510aa67/attachment.html>

More information about the NumPy-Discussion mailing list