I am new to python. I like to calculate average of the numbers by reading
the file 'digi_2.txt'. I have written the following code:
def average(s): return sum(s) * 1.0 / len(s)
f = open ("digi_2.txt", "r+")
list_of_lists1 = f.readlines()
for index in range(len(list_of_lists1)):
tt = li
Please trim unrelated text from emails.
On 21 March 2013 10:42, Arijit Ukil wrote:
> I am new to python. I like to calculate average of the numbers by reading
> the file 'digi_2.txt'. I have written the following code:
>
> def average(s): return sum(s) * 1.0 / len(s)
>
> f = open ("digi_2.txt",
On 03/21/2013 06:42 AM, Arijit Ukil wrote:
I am new to python.
Since you're new to Python, I won't try to supply you an answer using
list comprehensions, since you've probably not learned them yet.
I like to calculate average of the numbers by reading
the file 'digi_2.txt'. I have written
Hi Arijit,
On Thu, Mar 21, 2013 at 8:42 PM, Arijit Ukil wrote:
>
> I am new to python. I like to calculate average of the numbers by reading
> the file 'digi_2.txt'. I have written the following code:
>
> def average(s): return sum(s) * 1.0 / len(s)
>
> f = open ("digi_2.txt", "r+")
>
> list_of_l
On 03/21/2013 08:09 AM, Arijit Ukil wrote:
Thanks for the help.
You're welcome.
You replied privately, instead of including the list, so I'm forwarding
the response so everyone can see it. You also top-posted, so the
context is backwards.
After running your code, I am getting the follow
I have an elementary question provoked by another post today.
1. Is it the case that ALL imported data from a file is a string?
2. Does this therefor imply that said data has to be processed
appropriately to generate the data in the form required by the program?
3. Are there defined procedures
On Thu, Mar 21, 2013 at 11:43 PM, Shall, Sydney wrote:
> I have an elementary question provoked by another post today.
>
> 1. Is it the case that ALL imported data from a file is a string?
> 2. Does this therefor imply that said data has to be processed appropriately
> to generate the data in the
On 21/03/2013 13:54, Amit Saha wrote:
On Thu, Mar 21, 2013 at 11:43 PM, Shall, Sydney wrote:
I have an elementary question provoked by another post today.
1. Is it the case that ALL imported data from a file is a string?
2. Does this therefor imply that said data has to be processed appropriat
On 03/21/2013 09:43 AM, Shall, Sydney wrote:
I have an elementary question provoked by another post today.
1. Is it the case that ALL imported data from a file is a string?
No, the imported data is a module. For example
import sys
print type(sys)
At this point, sys is a object of
>> 3. Are there defined procedures for doing the required processing?
>
> If you meant conversion functions, int() and float() are examples of
> those. You of course (most of the times) have to make use of string
> manipulation functions (strip(), rstrip(), etc) to extract the exact
> data item yo
On 03/21/2013 10:03 AM, Dave Angel wrote:
A typo below; sorry.
On 03/21/2013 09:43 AM, Shall, Sydney wrote:
I have an elementary question provoked by another post today.
1. Is it the case that ALL imported data from a file is a string?
No, the imported data is a module. For example
On 21/03/13 13:43, Shall, Sydney wrote:
I have an elementary question provoked by another post today.
1. Is it the case that ALL imported data from a file is a string?
Assuming you mean data read from a file rather than modules imported
using 'import' then the answer is 'it depends'.
Most f
On 21/03/2013 16:17, Alan Gauld wrote:
On 21/03/13 13:43, Shall, Sydney wrote:
I have an elementary question provoked by another post today.
1. Is it the case that ALL imported data from a file is a string?
Assuming you mean data read from a file rather than modules imported
using 'import' t
Dear list,
I have been trying to understand out how to use iterators and in
particular groupby statements. I am, however, quite lost.
I wish to subset the below list, selecting the observations that have
an ID ('realtime_start') value that is greater than some date (i've
used the variable name m
On 03/21/2013 08:39 PM, Matthew Johnson wrote:
Dear list,
>
> I have been trying to understand out how to use iterators and in
> particular groupby statements. I am, however, quite lost.
>
> I wish to subset the below list, selecting the observations that have
> an ID ('realtime_start') value th
On 22/03/13 11:39, Matthew Johnson wrote:
Dear list,
I have been trying to understand out how to use iterators and in
particular groupby statements. I am, however, quite lost.
groupby is a very specialist function which is not very intuitive to
use. Sometimes I think that groupby is an excell
On 22/03/13 12:39, Mitya Sirenef wrote:
You can do it with groupby like so:
from itertools import groupby
from operator import itemgetter
maxDate = "2013-03-21"
mmax= list()
obs.sort(key=itemgetter('date'))
for k, group in groupby(obs, key=itemgetter('date')):
group = [dob for dob
On 03/21/2013 10:20 PM, Steven D'Aprano wrote:
On 22/03/13 12:39, Mitya Sirenef wrote:
>
>> You can do it with groupby like so:
>>
>>
>> from itertools import groupby
>> from operator import itemgetter
>>
>> maxDate = "2013-03-21"
>> mmax = list()
>>
>> obs.sort(key=itemgetter('date'))
>>
>> fo
18 matches
Mail list logo