MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: select from a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg69489] Re: [mg69477] select from a list
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Thu, 14 Sep 2006 06:55:14 -0400 (EDT)
  • Reply-to: hanlonr at cox.net

data={
      {"B5----Y", {1947, 1, 7}, 236.1, 236.1, 236.1, 236.1, 0, 0},
      {"B5----Y", {1947, 2, 9}, 236.1, 236.1, 236.1, 236.1, 0, 0},
      {"B5----Y", {1947, 2, 11}, 236.1, 236.1, 236.1, 236.1, 0, 0},
      {"B5----Y", {1948, 1, 9}, 236.1, 236.1, 236.1, 236.1, 0, 0},
      {"B5----Y", {1948, 2, 13}, 236.1, 236.1, 236.1, 236.1, 0, 0},
      {"B5----Y", {1948, 2, 13}, 236.1, 236.1, 236.1, 236.1, 0, 0},
      {"B5----Y", {1948, 3, 2}, 236.1, 236.1, 236.1, 236.1, 0, 0}};

I assume that your data is sorted by date. If not, sort. 

To select first entry of each year

First/@Split[data,#1[[2,1]]==#2[[2,1]]&]

{{"B5----Y", {1947, 1, 7}, 236.1, 236.1, 236.1, 236.1, 0, 
   0}, {"B5----Y", {1948, 1, 9}, 236.1, 236.1, 236.1, 
   236.1, 0, 0}}

To select the first entry of each month

First/@Split[data,#1[[2,2]]==#2[[2,2]]&]

{{"B5----Y", {1947, 1, 7}, 236.1, 236.1, 236.1, 236.1, 0, 
   0}, {"B5----Y", {1947, 2, 9}, 236.1, 236.1, 236.1, 
   236.1, 0, 0}, {"B5----Y", {1948, 1, 9}, 236.1, 236.1, 
   236.1, 236.1, 0, 0}, {"B5----Y", {1948, 2, 13}, 236.1, 
   236.1, 236.1, 236.1, 0, 0}, {"B5----Y", {1948, 3, 2}, 
   236.1, 236.1, 236.1, 236.1, 0, 0}}


Bob Hanlon

---- Steven Taracevicz <jk at starshooter.com> wrote: 
> hi:
> 
> i want to evaluate/plot historical pricing data.
> 
> the lists have this form:
> 
> {B5----Y, {1947, 1, 7}, 236.1, 236.1, 236.1, 236.1, 0, 0}
> i would like to select the first day of each year, and then the first day of 
> each month.
> thanks for the help!
> Steve 
> 
> 


  • Prev by Date: RE: init.m of FrontEnd in M5.2
  • Next by Date: Re: Known recursion link to Hermite polynomials not solved in Mathematica
  • Previous by thread: RE: select from a list
  • Next by thread: Result changing