jagmit sandhu wrote:
> python newbie. I can't understand the following about numpy arrays:
>
> x = np.array([[0, 1],[2,3],[4,5],[6,7]])
> x
> array([[0, 1],
>[2, 3],
>[4, 5],
>[6, 7]])
> x.shape
> (4, 2)
> y = x[:,0]
> y
> array([0, 2, 4, 6])
> y.shape
> (4,)
>
> Why is t
Il giorno giovedì 2 aprile 2020 06:30:22 UTC+2, jagmit sandhu ha scritto:
> python newbie. I can't understand the following about numpy arrays:
>
> x = np.array([[0, 1],[2,3],[4,5],[6,7]])
> x
> array([[0, 1],
>[2, 3],
>[4, 5],
>[6, 7]])
> x.shape
> (4, 2)
> y = x[:,0]
> y
Sharan Basappa writes:
> On Sunday, 8 September 2019 11:16:52 UTC-4, Luciano Ramalho wrote:
>> >>> int('C0FFEE', 16)
>> 12648430
>>
>> There you go!
>>
>> On Sun, Sep 8, 2019 at 12:02 PM Sharan Basappa
>> wrote:
>> >
>> > I have a numpy array that has data in the form of hex.
>> > I would li
On Sunday, 8 September 2019 11:16:52 UTC-4, Luciano Ramalho wrote:
> >>> int('C0FFEE', 16)
> 12648430
>
> There you go!
>
> On Sun, Sep 8, 2019 at 12:02 PM Sharan Basappa
> wrote:
> >
> > I have a numpy array that has data in the form of hex.
> > I would like to convert that into decimal/integ
>>> int('C0FFEE', 16)
12648430
There you go!
On Sun, Sep 8, 2019 at 12:02 PM Sharan Basappa wrote:
>
> I have a numpy array that has data in the form of hex.
> I would like to convert that into decimal/integer.
> Need suggestions please.
> --
> https://mail.python.org/mailman/listinfo/python-lis
On 05/18/2018 09:50 PM, Sharan Basappa wrote:
This is regarding numpy array. I am a bit confused how parts of the array are
being accessed in the example below.
1 import scipy as sp
2 data = sp.genfromtxt("web_traffic.tsv", delimiter="\t")
3 print(data[:10])
4 x = data[:,0]
5 y = data[:,1]
App
The "indexing" page of the documentation might help you with this:
https://docs.scipy.org/doc/numpy-1.14.0/reference/arrays.indexing.html
On 05/18/2018 09:50 PM, sharan.basa...@gmail.com wrote:
This is regarding numpy array. I am a bit confused how parts of the array are
being accessed in the
>> I think that you want
>>
>> P * R[;,None]
>
> Sorry, I meant
>
> P * R[:, None]
>
> Manolo
Muchísimas gracias, Manolo. Eres un genio y me has ayudado mucho. Te debo una.
--
https://mail.python.org/mailman/listinfo/python-list
On 03/20/15 at 02:11pm, Manolo Martínez wrote:
> On 03/20/15 at 01:46pm, Mr. Twister wrote:
>
> > I have two numpy arrays:
[...]
> > Is there a direct, single expression command to get this result?
>
> I think that you want
>
> P * R[;,None]
Sorry, I meant
P * R[:, None]
Manolo
On 03/20/15 at 01:46pm, Mr. Twister wrote:
> I have two numpy arrays:
>
> >>> P
> array([[[ 2, 3],
> [33, 44],
> [22, 11],
> [ 1, 2]]])
> >>> R
> array([0, 1, 2, 3])
>
> the values of these may of course be different. The important fact is that:
>
> >>> P.shape
> (1,
Thank you very much!
--
https://mail.python.org/mailman/listinfo/python-list
LJ wrote:
> Thank you for the reply.
>
> So, as long as I access and modify the elements of, for example,
>
> A=array([[set([])]*4]*3)
>
>
> as (for example):
>
> a[0][1] = a[0][1] | set([1,2])
>
> or:
>
> a[0][1]=set([1,2])
>
> then I should have no problems?
As long as you set (i. e. re
Thank you for the reply.
So, as long as I access and modify the elements of, for example,
A=array([[set([])]*4]*3)
as (for example):
a[0][1] = a[0][1] | set([1,2])
or:
a[0][1]=set([1,2])
then I should have no problems?
--
https://mail.python.org/mailman/listinfo/python-list
LJ wrote:
> Wolfgang, thank you very much for your reply.
>
> Following the example in the link, the problem appears:
>
A = [[0]*2]*3
You can see this as a shortcut for
value = 0
inner = [value, value]
A = [inner, inner, inner]
When the value is mutable (like your original set) a modific
Wolfgang, thank you very much for your reply.
Following the example in the link, the problem appears:
>>> A = [[0]*2]*3
>>> A
[[0, 0], [0, 0], [0, 0]]
>>> A[0][0] = 5
>>> A
[[5, 0], [5, 0], [5, 0]]
Now, if I use a numpy array:
>>> d=array([[0]*2]*3)
>>> d
array([[0, 0],
[0, 0],
[0
On 25.05.2014 00:14, Robert Kern wrote:
On 2014-05-24 23:05, Luis José Novoa wrote:
Hi All,
Hope you're doing great. One quick question. I am defining an array of
sets using numpy as:
a=array([set([])]*3)
Has nothing to do with numpy, but the problem is exclusively with your
innermost expr
On 2014-05-24 23:05, Luis José Novoa wrote:
Hi All,
Hope you're doing great. One quick question. I am defining an array of sets
using numpy as:
a=array([set([])]*3)
Now, if I want to add an element to the set in, lets say, a[0], and I use the
.add(4) operation, which results in:
array([set(
On 1/29/2013 1:49 PM, Alok Singhal wrote:
On Tue, 29 Jan 2013 00:41:54 -0800, C. Ng wrote:
Is there a numpy operation that does the following to the array?
1 2 ==> 4 3
3 4 2 1
Thanks in advance.
How about:
import numpy as np
a = np.array([[1,2],[3,4]])
a
array([[1, 2], [3, 4]])
On Tue, 29 Jan 2013 00:41:54 -0800, C. Ng wrote:
> Is there a numpy operation that does the following to the array?
>
> 1 2 ==> 4 3
> 3 4 2 1
>
> Thanks in advance.
How about:
>>> import numpy as np
>>> a = np.array([[1,2],[3,4]])
>>> a
array([[1, 2],
[3, 4]])
>>> a[::-1, ::-1]
On Tuesday, January 29, 2013 3:41:54 AM UTC-5, C. Ng wrote:
> Is there a numpy operation that does the following to the array?
>
>
>
> 1 2 ==> 4 3
>
> 3 4 2 1
>
>
>
> Thanks in advance.
>>> import numpy as np
>>> a=np.array([[1,2],[3,4]])
>>> a
array([[1, 2],
[3, 4]])
>>> np.
C. Ng wrote:
> Is there a numpy operation that does the following to the array?
>
> 1 2 ==> 4 3
> 3 4 2 1
How about
>>> a
array([[1, 2],
[3, 4]])
>>> a[::-1].transpose()[::-1].transpose()
array([[4, 3],
[2, 1]])
Or did you mean
>>> a.reshape((4,))[::-1].reshape((2,2))
ar
On 2009-08-10 17:38, Nathan wrote:
Is there an easy way to merge two numpy arrays with different rank
sizes (terminology?).
You will want to ask numpy questions on the numpy mailing list.
http://www.scipy.org/Mailing_Lists
I believe that "shape" is the term you are looking for.
I want to
>> Is there any reason the 'axis' keyword argument doesn't default to the
>> value that corresponds to python list behaviour? That would make lot
>> of sense I think. Or retaining compatibility with python lists is not
>> really a goal of numpy.array?
>
> Not at all. It's an entirely different data
On 2009-03-28 22:35, Daniel Fetchinson wrote:
Is there any reason the 'axis' keyword argument doesn't default to the
value that corresponds to python list behaviour? That would make lot
of sense I think. Or retaining compatibility with python lists is not
really a goal of numpy.array?
Not at al
>> The fact that the following two outputs are not the same is a bug or a
>> feature of numpy?
>>
>> # I would have thought the two array outputs would be the same ##
>>
>> import numpy
>>
>> a = [ [ 0, 0 ], [ 1, 0 ], [ 1, 1 ] ]
>>
>> pythonarray = a
>> pythonarray.sort( )
>> print pythonar
On Sun, 29 Mar 2009, Daniel Fetchinson wrote:
[...]
> The fact that the following two outputs are not the same is a bug or a
> feature of numpy?
>
> # I would have thought the two array outputs would be the same ##
>
> import numpy
>
> a = [ [ 0, 0 ], [ 1, 0 ], [ 1, 1 ] ]
>
> pythonarray
Daniel Fetchinson wrote:
So far I was working under the assumption that the numpy array
implementation can be used as a drop-in replacement for native python
lists, i.e. wherever I see a list 'a' and I want to speed up my
numerical calculations I just replace it with 'numpy.array( a )' and
everyt
>> So far I was working under the assumption that the numpy array
>> implementation can be used as a drop-in replacement for native python
>> lists, i.e. wherever I see a list 'a' and I want to speed up my
>> numerical calculations I just replace it with 'numpy.array( a )' and
>> everything will wo
Sean Davis wrote:
I have a set of numpy arrays which I would like to save to a gzip
file. Here is an example without gzip:
b=numpy.ones(100,dtype=numpy.uint8)
a=numpy.zeros(100,dtype=numpy.uint8)
fd = file('test.dat','wb')
a.tofile(fd)
b.tofile(fd)
fd.close()
This works fine. However,
On Jun 11, 12:42 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> On Jun 11, 9:17 am, Sean Davis <[EMAIL PROTECTED]> wrote:
>
>
>
> > I have a set of numpy arrays which I would like to save to a gzip
> > file. Here is an example without gzip:
>
> > b=numpy.ones(100,dtype=numpy.uint8)
> > a
On Jun 11, 9:17 am, Sean Davis <[EMAIL PROTECTED]> wrote:
> I have a set of numpy arrays which I would like to save to a gzip
> file. Here is an example without gzip:
>
> b=numpy.ones(100,dtype=numpy.uint8)
> a=numpy.zeros(100,dtype=numpy.uint8)
> fd = file('test.dat','wb')
> a.tofile(fd)
sturlamolden wrote:
> Enthought and similar distros are in my experience "unclean". They
> don't always work and they are difficult to update. I rather download
> the binary installers (for Windows) and install the packages I need.
Right, that's why we (I'm an Enthought employee) haven't been upda
[EMAIL PROTECTED] wrote:
> Thanks a lot for your reply.
> I'll have a look at the numpy-discussion for future issues.
>
> FYI, I'm using Python 2.4.3 for Windows (Enthought Edition) and the
> included IPython shell. I found my mistake; importing of pylab.
> E.g., this works
> from pylab import * ;
On 13 Jul, 22:52, [EMAIL PROTECTED] wrote:
> It seems a bit risky to use 'from scipy import *'. Maybe it's better
> to use 'import scipy' and then scipy.arange, to be sure what is
> actually being used? Would there be any disadvanages with that
> approach, other than more use of the keyboard?
Gen
Thanks a lot for your reply.
I'll have a look at the numpy-discussion for future issues.
FYI, I'm using Python 2.4.3 for Windows (Enthought Edition) and the
included IPython shell. I found my mistake; importing of pylab.
E.g., this works
from pylab import * ; from scipy import * ; y = arange(3) ;
>>> from numpy import *
>>> from numpy.random import *
>>> N = 100
>>> input = sign(randn(N))
>>> a = arange(N)
>>> output = zeros(N)
>>> output[input < 0] = 10 * a[input < 0]
>>> output[input > 0] = 20 * a[input > 0]
>>>
Worked fine for me.
S.M.
--
http://mail.python.org/mailman/list
[EMAIL PROTECTED] wrote:
> Being a Matlab user wanting to switch to Python/SciPy,
Fantastic! You might be interested in joining the numpy mailing list. There are
a lot more of us numpy devs and users there than here.
http://www.scipy.org/Mailing_Lists
> I'd like to
> know how the following Mat
37 matches
Mail list logo