Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have hourly registered data as :

Sort[Join @@ data[[All, 3 ;;]][[All, All, 2 ;; 3]]]
output={{{2013, 6, 19, 12, 0, 0.}, 7980.}, {{2013, 6, 19, 13, 0, 0.}, 
7994.}, {{2013, 6, 19, 14, 0, 0.}, 7860.}, {{2013, 6, 19, 15, 0, 0.}, 
7722.}, {{2013, 6, 19, 16, 0, 0.},  7602.}, {{2013, 6, 19, 17, 0, 0.}, 
7479.}, {{2013, 6, 19, 18, 0, 0.}, 7354.}, {{2013, 6, 19, 19, 0, 0.}, 
7319.}, {{2013, 6, 19, 20, 0, 0.}, 7347.}, {{2013, 6, 19, 21, 0, 0.}, 
7071.}, {{2013, 6, 19, 22, 0, 0.}, 6928.}, {{2013, 6, 19, 23, 0, 0.}, 6854.}, 
{{2013, 6, 20, 0, 0, 0.},6559.}, {{2013, 6, 20, 1, 0, 0.}, 6145.}, 
{{2013, 6, 20, 2, 0,0.}, 5920.}, {{2013, 6, 20, 3, 0, 0.}, 5686.}, 
{{2013, 6, 20, 4, 0, 0.},5696.}, 
{{2013, 6, 20, 5, 0, 0.}, 5901.}, {{2013, 6, 20, 6, 0, 0.},
6684.}, {{2013, 6, 20, 7, 0, 0.}, 7368.}, {{2013, 6, 20, 8, 0, 0.},
7699.}, {{2013, 6, 20, 9, 0, 0.}, 7884.}, {{2013, 6, 20, 10, 0, 0.}, 
7958.}, {{2013, 6, 20, 11, 0, 0.},{ 7984.}, {{2013, 6, 20, 12, 0, 0.}, 
7930.}, {{2013, 6, 20, 13, 0, 0.}, 7792.}, {{2013, 6, 20, 14, 0, 0.}, 
7588.}, {{2013, 6, 20, 15, 0, 0.}, 7479.}, {{2013, 6, 20, 16, 0, 0.}, 
7349.}, {{2013, 6, 20, 17, 0, 0.},  7253.}, {{2013, 6, 20, 18, 0, 0.}, 
7171.}, {{2013, 6, 20, 19, 0, 0.}, 7106.}, {{2013, 6, 20, 20, 0, 0.}, 
7044.}, {{2013, 6, 20, 21, 0, 0.}, 6711.}, {{2013, 6, 20, 22, 0, 0.}, 
6647.}, {{2013, 6, 20, 23, 0, 0.}, 6648.}}

I want to have the mean of the each day and the same time consequences just exclude the hours.Could you please help on the code.

share|improve this question
    
If you would provide some actual sample data, it will be so much more convenient for other to help. Some more detail on what you have tried already and how exactly your result should look like will do so, too. –  Yves Klett Jun 24 '13 at 7:40
    
@YvesKlett I added –  Alex Jun 24 '13 at 9:27
add comment

1 Answer

up vote 2 down vote accepted

Here's something to get you started:

Since you didn't provide any random data, here's some (with modifications for the 26th of each month):

dd = Sort@
Table[{{2004, RandomInteger[{1, 12}], RandomInteger[{1, 31}], 
   RandomInteger[{0, 24}], 0, 0.}, RandomInteger[{10, 50}]}, 
  {n, 0, 2000}] /. 
  {{2004, mn_, 26, h_, m_, s_}, n_} ->  {{2004, mn, 26, h, m, s}, 1000};

...

{{{2004, 1, 1, 15, 0, 0.}, 50}, 
 {{2004, 1, 1, 18, 0, 0.}, 24},
 {{2004, 1, 1, 20, 0, 0.}, 18}},
 ...

Collect the data:

days = Gather[dd, 
   DateString[First@#1, "DateShort"] == 
   DateString[First@#2, "DateShort"] &];

Compile the totals:

dt = Table[
    {days[[x, 1, 1, 1 ;; 3]], Total[days[[x, All, 2]]]}, 
  {x, 1, Length[days]}];

...

{{{2004, 1, 1}, 92}, 
 {{2004, 1, 1}, 79}, 
 {{2004, 1, 3}, 118},
 ...

See if the 26th is showing:

DateListPlot[dt, Joined -> True, Filling -> Bottom, 
  PlotStyle -> Directive[Thin, Black]]

It looks like it might work.

From here, the means should be easy.

datelistplot

share|improve this answer
    
Many thanks.and very nice gavater.I saw the code as well.Frankly how long does it take for me to write such thing?!!! –  Alex Jun 24 '13 at 9:38
    
@alex Should take about two minutes typing, but copy/paste is quicker... :) –  cormullion Jun 24 '13 at 9:46
    
I know but Skills I mean.How long have you been coding? –  Alex Jun 24 '13 at 9:59
    
@alex my first question! but I'm a slow learner... –  cormullion Jun 24 '13 at 10:05
    
that is nice.great.But I think you did well and you were good not slow.Your background is in programming? –  Alex Jun 24 '13 at 10:20
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.