Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #104489
| From | Val Krem <valkrem@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Read and count |
| Date | 2016-03-09 21:30 +0000 |
| Message-ID | <mailman.116.1457599150.15725.python-list@python.org> (permalink) |
| References | <2095750566.7009618.1457559033672.JavaMail.yahoo.ref@mail.yahoo.com> |
Hi all,
I am a new learner about python (moving from R to python) and trying read and count the number of observation by year for each city.
The data set look like
city year x
XC1 2001 10
XC1 2001 20
XC1 2002 20
XC1 2002 10
XC1 2002 10
Yv2 2001 10
Yv2 2002 20
Yv2 2002 20
Yv2 2002 10
Yv2 2002 10
out put will be
city
xc1 2001 2
xc1 2002 3
yv1 2001 1
yv2 2002 3
Below is my starting code
count=0
fo=open("dat", "r+")
str = fo.read();
print "Read String is : ", str
fo.close()
Many thanks
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Read and count Val Krem <valkrem@yahoo.com> - 2016-03-09 21:30 +0000
Re: Read and count Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-03-10 11:11 +0200
Re: Read and count Peter Otten <__peter__@web.de> - 2016-03-10 10:33 +0100
Re: Read and count Val Krem <valkrem@yahoo.com> - 2016-03-10 11:09 -0600
csiph-web