MathGroup Archive 2008

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

Search the Archive

Intersection of lists of lists based on the first term

There is something I've been doing inefficiently that I think might be done
much better, and was hoping folks here could help.

I am working with time series data in the form
where the many of the timestamps will be in common between the series, but
not all.

I frequently need to work with only those data which are available in all
the time series, and I have written a function that does this, in the
simplest case, by first working out the timestamps that all the series share
in common

timestampsincommon=Intersection @@ Map[Transpose[#][[1]] &,

then running Select based on MemberQ

Map[Select[#, MemberQ[timestampsincommon, #[[1]]] &] &,

This works, but the completion time increases roughly linearly with the
number of datapoints involved, and is slow when the number of points gets
large, and it seems inelegant. I was hoping somebody on the list might
suggest a better way.

Thank you,


  • Prev by Date: Re: A Problem with Simplify
  • Next by Date: Re: Path, Get, etc.
  • Previous by thread: Re: ContourPlot, etc.: not every point a Real
  • Next by thread: Re: Intersection of lists of lists based on the first term