[Tutor] summary stats grouped by month year

शंतनू shantanoo at gmail.com
Tue May 8 09:43:39 CEST 2012


On Tue, May 8, 2012 at 12:46 PM, शंतनू <shantanoo at gmail.com> wrote:
> Python generally comes with support for sqlite3.
>
> you can store your date in to sqlite db and then try running sql query
> for finding of the details.

data not date.

>
> select year, sum(MeanRain) where year='1972' group by year;
> select month, sum(MeanRain) where month='Jan' group by month;
>
> ** Not sure regarding the exact sql query. sum function and 'group by'
> is important.
>
> On Tue, May 8, 2012 at 11:37 AM, questions anon
> <questions.anon at gmail.com> wrote:
>> I would like to calculate summary statistics of rainfall based on year and
>> month.
>> I have the data in a text file (although could put in any format if it
>> helps) extending over approx 40 years:
>> YEAR MONTH    MeanRain
>> 1972 Jan    12.7083199
>> 1972 Feb    14.17007142
>> 1972 Mar    14.5659302
>> 1972 Apr    1.508517302
>> 1972 May    2.780009889
>> 1972 Jun    1.609619287
>> 1972 Jul    0.138150181
>> 1972 Aug    0.214346148
>> 1972 Sep    1.322102228
>>
>> I would like to be able to calculate the total rain annually:
>>
>> YEAR   Annualrainfall
>> 1972    400
>> 1973    300
>> 1974    350
>> ....
>> 2011     400
>>
>> and also the monthly mean rainfall for all years:
>>
>> YEAR  MonthlyMeanRain
>> Jan      13
>> Feb      15
>> Mar       8
>> .....
>> Dec       13
>>
>>
>> Is this something I can easily do?
>> I have started by simply importing the text file but data is not represented
>> as time so that is probably my first problem and then I am not sure how to
>> group them by month/year.
>>
>> textfile=r"textfile.txt"
>> f=np.genfromtxt(textfile,skip_header=1)
>>
>> Any feedback will be greatly appreciated.
>>
>>
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>>


More information about the Tutor mailing list