Login Register


Issues with numpy or more likely myself. filter_list
Author
Message
Issues with numpy or more likely myself. #1
*snip*
“The first principle is that you must not fool yourself and you are the easiest person to fool.” - Feynman

Reply

RE: Issues with numpy or more likely myself. #2
I have not used Numpy but you should see Array section of this website http://www.scipy.org/Tentative_NumPy_Tut...b6467cd5a4
My Blog: http://www.procurity.wordpress.com
Donations: 1HLjiSbnWMpeQU46eUVCrYdbkrtduX7snG

Reply

RE: Issues with numpy or more likely myself. #3
Please explain or make a small example: What is the content of the txt file and what output do you expect?
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

RE: Issues with numpy or more likely myself. #4
(04-12-2013, 07:07 PM)Deque Wrote: Please explain or make a small example: What is the content of the txt file and what output do you expect?

Apologies for my lack of clarity. The file being imported is simply two columns of one hundred lines of data. I'm trying to manipulate the data such that I can work out statistical properties such as the mean by:
Code:
mean = sum(x)/100.0
However the [x] array I am trying to read from is not being registered and consequently python is giving me a default array of numbers from one to hundred.

More specifically the plotted data follows a trend of which I am familiar with and know the general equation of. My intent is to try and fit this general curve to the data set and compare with other curve fittings using inbuilt routines from other Python modules.
“The first principle is that you must not fool yourself and you are the easiest person to fool.” - Feynman

Reply

RE: Issues with numpy or more likely myself. #5
(04-12-2013, 07:24 PM)-ELM Wrote:
(04-12-2013, 07:07 PM)Deque Wrote: Please explain or make a small example: What is the content of the txt file and what output do you expect?

Apologies for my lack of clarity. The file being imported is simply two columns of one hundred lines of data. I'm trying to manipulate the data such that I can work out statistical properties such as the mean by:
Code:
mean = sum(x)/100.0
However the [x] array I am trying to read from is not being registered and consequently python is giving me a default array of numbers from one to hundred.

More specifically the plotted data follows a trend of which I am familiar with and know the general equation of. My intent is to try and fit this general curve to the data set and compare with other curve fittings using inbuilt routines from other Python modules.

I well understood what you want to do. But I need an example of how your file looks like.
You say you get an array with numbers from 1 to 100 in it. There is a reason for this and to find the reason properly I need a little and concrete example of the contents of your txt file (I guess a few lines would be sufficient).

I see that there is similar example here: http://docs.scipy.org/doc/numpy/referenc...adtxt.html

Code:
>>> c = StringIO("1,0,2\n3,0,4") >>> x, y = np.loadtxt(c, delimiter=',', usecols=(0, 2), unpack=True) >>> x array([ 1., 3.]) >>> y array([ 2., 4.])

But here they specified a delimiter and which columns to put in x and y. You didn't specify that, so I am asking myself what kind of data you expect to be in x, if there are not several columns you can unpack.

The only thing that gives me more clarity is your .txt file.
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

RE: Issues with numpy or more likely myself. #6
(04-12-2013, 07:49 PM)Deque Wrote:
(04-12-2013, 07:24 PM)-ELM Wrote:
(04-12-2013, 07:07 PM)Deque Wrote: Please explain or make a small example: What is the content of the txt file and what output do you expect?

Apologies for my lack of clarity. The file being imported is simply two columns of one hundred lines of data. I'm trying to manipulate the data such that I can work out statistical properties such as the mean by:
Code:
mean = sum(x)/100.0
However the [x] array I am trying to read from is not being registered and consequently python is giving me a default array of numbers from one to hundred.

More specifically the plotted data follows a trend of which I am familiar with and know the general equation of. My intent is to try and fit this general curve to the data set and compare with other curve fittings using inbuilt routines from other Python modules.

I well understood what you want to do. But I need an example of how your file looks like.
You say you get an array with numbers from 1 to 100 in it. There is a reason for this and to find the reason properly I need a little and concrete example of the contents of your txt file (I guess a few lines would be sufficient).

I see that there is similar example here: http://docs.scipy.org/doc/numpy/referenc...adtxt.html

Code:
>>> c = StringIO("1,0,2\n3,0,4") >>> x, y = np.loadtxt(c, delimiter=',', usecols=(0, 2), unpack=True) >>> x array([ 1., 3.]) >>> y array([ 2., 4.])

But here they specified a delimiter and which columns to put in x and y. You didn't specify that, so I am asking myself what kind of data you expect to be in x, if there are not several columns you can unpack.

The only thing that gives me more clarity is your .txt file.

Yeah I was using usecols=[0,1] previously but as there are only two columns of data and two arrays are being defined from these columns so I simply omitted it for self clarity. Having saved the data file under a different name and retyped the code countless times it has now decided to work. I have no idea what was going wrong previously but apologies for wasting your time! A huge thanks for your efforts in assisting me nonetheless.

EDIT: Shall I delete the thread or leave for a moderator to mark it as solved?
“The first principle is that you must not fool yourself and you are the easiest person to fool.” - Feynman

Reply

RE: Issues with numpy or more likely myself. #7
-marked as solved-
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply







Users browsing this thread: 1 Guest(s)