|
|
-
removing dupes from a bag while saving first occurrence
Chan, Tim 2013-03-08, 22:00
If I have a bag and would like to remove dupes, while saving the first occurrence, is this possible?
For example, for the following bag:
(group_1,{(2012-12-15,a),(2012-12-17,a),(2012-12-23,c)})
I would like my result to be the following:
(group_1,{(2012-12-15,a),(2012-12-23,c)})
+
Chan, Tim 2013-03-08, 22:00
-
Re: removing dupes from a bag while saving first occurrence
Norbert Burger 2013-03-08, 22:10
Looking at your sample, it seems you have a GROUPBY generating these bags...? Could you just insert a DISTINCT before this GROUP BY?
Norbert
On Fri, Mar 8, 2013 at 5:00 PM, Chan, Tim <[EMAIL PROTECTED]> wrote:
> If I have a bag and would like to remove dupes, while saving the first > occurrence, is this possible? > > For example, for the following bag: > > (group_1,{(2012-12-15,a),(2012-12-17,a),(2012-12-23,c)}) > > I would like my result to be the following: > > (group_1,{(2012-12-15,a),(2012-12-23,c)}) >
+
Norbert Burger 2013-03-08, 22:10
-
Re: removing dupes from a bag while saving first occurrence
Chan, Tim 2013-03-08, 23:12
Using a distinct before the group by does not guarantee the date order. I need to keep the earliest occurrence of 'a' and discard all later occurrences of 'a'. On Fri, Mar 8, 2013 at 2:10 PM, Norbert Burger <[EMAIL PROTECTED]>wrote:
> Looking at your sample, it seems you have a GROUPBY generating these > bags...? Could you just insert a DISTINCT before this GROUP BY? > > Norbert > > On Fri, Mar 8, 2013 at 5:00 PM, Chan, Tim <[EMAIL PROTECTED]> wrote: > > > If I have a bag and would like to remove dupes, while saving the first > > occurrence, is this possible? > > > > For example, for the following bag: > > > > (group_1,{(2012-12-15,a),(2012-12-17,a),(2012-12-23,c)}) > > > > I would like my result to be the following: > > > > (group_1,{(2012-12-15,a),(2012-12-23,c)}) > > >
+
Chan, Tim 2013-03-08, 23:12
-
Re: removing dupes from a bag while saving first occurrence
Panshul Whisper 2013-03-08, 23:18
Did u try to order them by date before grouping them? On Mar 9, 2013 12:12 AM, "Chan, Tim" <[EMAIL PROTECTED]> wrote:
> Using a distinct before the group by does not guarantee the date order. I > need to keep the earliest occurrence of 'a' and discard all later > occurrences of 'a'. > > > On Fri, Mar 8, 2013 at 2:10 PM, Norbert Burger <[EMAIL PROTECTED] > >wrote: > > > Looking at your sample, it seems you have a GROUPBY generating these > > bags...? Could you just insert a DISTINCT before this GROUP BY? > > > > Norbert > > > > On Fri, Mar 8, 2013 at 5:00 PM, Chan, Tim <[EMAIL PROTECTED]> wrote: > > > > > If I have a bag and would like to remove dupes, while saving the first > > > occurrence, is this possible? > > > > > > For example, for the following bag: > > > > > > (group_1,{(2012-12-15,a),(2012-12-17,a),(2012-12-23,c)}) > > > > > > I would like my result to be the following: > > > > > > (group_1,{(2012-12-15,a),(2012-12-23,c)}) > > > > > >
+
Panshul Whisper 2013-03-08, 23:18
-
Re: removing dupes from a bag while saving first occurrence
Panshul Whisper 2013-03-08, 23:21
I think u should.. Group then... In a nested foreach.. order each group records by date.. Then in another nested foreach perform the distinct in each group.. This should pick the first element in each group. On Mar 9, 2013 12:18 AM, "Panshul Whisper" <[EMAIL PROTECTED]> wrote:
> Did u try to order them by date before grouping them? > On Mar 9, 2013 12:12 AM, "Chan, Tim" <[EMAIL PROTECTED]> wrote: > >> Using a distinct before the group by does not guarantee the date order. I >> need to keep the earliest occurrence of 'a' and discard all later >> occurrences of 'a'. >> >> >> On Fri, Mar 8, 2013 at 2:10 PM, Norbert Burger <[EMAIL PROTECTED] >> >wrote: >> >> > Looking at your sample, it seems you have a GROUPBY generating these >> > bags...? Could you just insert a DISTINCT before this GROUP BY? >> > >> > Norbert >> > >> > On Fri, Mar 8, 2013 at 5:00 PM, Chan, Tim <[EMAIL PROTECTED]> wrote: >> > >> > > If I have a bag and would like to remove dupes, while saving the first >> > > occurrence, is this possible? >> > > >> > > For example, for the following bag: >> > > >> > > (group_1,{(2012-12-15,a),(2012-12-17,a),(2012-12-23,c)}) >> > > >> > > I would like my result to be the following: >> > > >> > > (group_1,{(2012-12-15,a),(2012-12-23,c)}) >> > > >> > >> >
+
Panshul Whisper 2013-03-08, 23:21
|
|