MathGroup Archive 2012

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

Search the Archive

Re: Removing rows from a table

  • To: mathgroup at smc.vnet.net
  • Subject: [mg128728] Re: Removing rows from a table
  • From: Dana DeLouis <dana01 at me.com>
  • Date: Wed, 21 Nov 2012 19:48:54 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net

Hi.  Here's just another idea.
Here's some data with months 1 thru 8.
We'll remove months 2,4,6.

data = 
{
{"01/01/2010 06:15",1,2,3,0,0,0},
{"02/05/2010 07:15",4,5,6,0,0,0},
{"03/07/2010 08:15",7,8,9,0,0,0},
{"04/08/2010 09:15",10,11,12,0,0,0},
{"05/05/2010 06:15",13,14,15,0,0,0},
{"06/06/2010 07:15",16,17,18,0,0,0},
{"07/07/2010 08:15",19,20,21,0,0,0},
{"08/08/2010 09:15",22,23,24,0,0,0}
};

del=
{
{{2010,2,1,12,0,0.0},{2010,2,15,12,0,0.0}},
{{2010,4,1,12,0,0.0},{2010,4,15,12,0,0.0}},
{{2010,6,1,12,0,0.0},{2010,6,15,12,0,0.0}}
};

// First, convert your data

data[[All,1]]=AbsoluteTime[DateList[{#,{"Month","Day","Year","Hour","Minute"}}]]&/@data[[All,1]];

del=Map[AbsoluteTime,del,{2}];

// A Helper Function, or use Pure Function

Fx[m_,r_]:=DeleteCases[m,n_/;( Median[Append[r,First[n]]]==First[n]  )]

// Your new data

new = Fold[Fx,data,del]  ;

// Convert it back to DateList

new[[All,1]] = DateList/@new[[All,1]];

new

{
{{2010,1,1,6,15,0.},1,2,3,0,0,0},
{{2010,3,7,8,15,0.},7,8,9,0,0,0},
{{2010,5,5,6,15,0.},13,14,15,0,0,0},
{{2010,7,7,8,15,0.},19,20,21,0,0,0},
{{2010,8,8,9,15,0.},22,23,24,0,0,0}
}

// Months 2,4 & 6 are removed.

= = = = = = = = = =
HTH  :>)
Dana DeLouis
Mac & Mathematica 8
= = = = = = = = = =


On Sunday, November 18, 2012 5:17:44 PM UTC-5, Citzen90210 wrote:
> Total nubie here and struggling!
> 
> 
> 
> I have a dataset of approximately 100,000 records of data points recorded at 15 minute intervals.  Each row looks something like this:
> 
> 
> 
> {"01/01/2010 06:15", 0.04375, 4.96188, 1.00885, 0, 0, 0}
> 
> 
> 
> I've worked out how to parse the date column so that seems to be under control but now I have a list of date ranges that I need to remove from the dataset.  The date ranges to be removed look something like this:
> 
> 
> 
> {{2010, 2, 1, 12, 0, 0.0}, {2010, 2, 15, 12, 0, 0.0}},
> 
> {{2010, 7, 1, 12, 0, 0.0}, {2010, 7, 15, 12, 0, 0.0}}
> 
> 
> 
> with the first column representing the start date of the block to be removed and the second column representing the end date of the block, multiple rows represent multiple blocks to be removed and the total number of blocks is variable.
> 
> 
> 
> Ideally I'd like to be able to use Drop or Delete to remove the offending blocks of data but I want to be able to somehow feed the command with the date range table and have it remove the ranges all in one go.
> 
> 
> 
> I'm not having much luck working this out for myself and would love to get a few pointers.









  • Prev by Date: Re: Removing rows from a table
  • Next by Date: Notice of New Presentations Update
  • Previous by thread: Re: Removing rows from a table
  • Next by thread: Re: Removing rows from a table