2
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Yves Klett Jun 24 '13 at 7:40
  • $\begingroup$ @YvesKlett I added $\endgroup$ – Alex Jun 24 '13 at 9:27
2
$\begingroup$

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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