Delete elements less than the last largest elementDeleting multiple elements from a listChanging the precision of data in a list of matricesJoin nested lists based on first and last elements within each listUsing Select function to select elements based on last element of nested listDelete only when there are two (or more) 1smaking two columns from 1D-horizontal dataDelete some elements based on the keysHow to set a particular element of a list to a number?delete an element list recursivelyElegant way of partitioning in two starting from the second element?

What do you call a situation where you have choices but no good choice?

Delete elements less than the last largest element

Chilling water in copper vessel

How to evaluate the performance of open source solver?

When do flights get cancelled due to fog?

Moving millions of files to a different directory with specfic name patterns

How was the website able to tell my credit card was wrong before it processed it?

Why did Robert F. Kennedy loathe Lyndon B. Johnson?

What are the effects of abstaining from eating a certain flavor?

Need a non-volatile memory IC with near unlimited read/write operations capability

What exactly is a "murder hobo"?

Interpretation of non-significant results as "trends"

Curly braces adjustment in tikz?

With a data transfer of 50 GB estimated 5 hours, are USB-C claimed speeds inaccurate or to blame?

Tesco's Burger Relish Best Before End date number

Where are the Wazirs?

What factors could lead to bishops establishing monastic armies?

Is it okay to use open source code to do an interview task?

Sense of humor in your sci-fi stories

What was the significance of Spider-Man: Far From Home being an MCU Phase 3 film instead of a Phase 4 film?

Gory anime with pink haired girl escaping an asylum

Is it possible for a character at any level to cast all 44 Cantrips in one week without Magic Items?

How does one acquire an undead eyeball encased in a gem?

What was the profession 芸者 (female entertainer) called in Russia?



Delete elements less than the last largest element


Deleting multiple elements from a listChanging the precision of data in a list of matricesJoin nested lists based on first and last elements within each listUsing Select function to select elements based on last element of nested listDelete only when there are two (or more) 1smaking two columns from 1D-horizontal dataDelete some elements based on the keysHow to set a particular element of a list to a number?delete an element list recursivelyElegant way of partitioning in two starting from the second element?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3












$begingroup$


Here is my list. The first column contains its index and second column has data.



list=1, 170.93, 2, 170.4, 3, 174.08, 4, 160.65, 5, 166.44, 6, 
169.75, 7, 175.86, 8, 177.6, 9, 180.27, 10, 182.82, 11,
182.02, 12, 186.65, 13, 184.53, 14, 186.17, 15,
177.29, 16, 172.06, 17, 175.58, 18, 168.09, 19,
172.33, 20, 165.1, 21, 154.88, 22, 161.28, 23, 165.25, 24,
165.15, 25, 171.03, 26, 174.55, 27, 182.57, 28,
191.02, 29, 191.11, 30, 184.93, 31, 188.85, 32, 191.44;


I want to delete all numbers that are smaller than the last largest element. For example, I want to delete 4th, 5th and 6th elements because they are smaller than the last largest element (3rd). Similarly, I want to delete elements from 13th to 27th elements because they are smaller than the last largest element (12th). 30th and 31st elements should be deleted because they are smaller than prior largest element (29th). Final results should contain increasing numbers. Here is the tabular representation of the data:



enter image description here



I did my best to explain my problem. Please write in the comment if it is not clear. I have a big data and I need to manipulate it as explained here. Any help would be greatly appreciated. Thanks










share|improve this question









$endgroup$







  • 4




    $begingroup$
    DeleteDuplicatesBy[ Transpose[list[[All, 1]], FoldList[Max, list[[All, 2]]]], Last] should do what you're after.
    $endgroup$
    – ciao
    8 hours ago










  • $begingroup$
    Should you also be deleting the second element since it is smaller than the first? I will note that the solution from @ciao does remove the second element.
    $endgroup$
    – Mark R
    7 hours ago











  • $begingroup$
    @ Mark R, yes you are right. I missed it. Thanks
    $endgroup$
    – DestinationLess_Traveller
    7 hours ago






  • 2




    $begingroup$
    DeleteDuplicates[list, #1[[2]] > #2[[2]] &]
    $endgroup$
    – Bob Hanlon
    7 hours ago










  • $begingroup$
    @ Bob, thanks for your simple answer. I really appreciate it.
    $endgroup$
    – DestinationLess_Traveller
    2 hours ago

















3












$begingroup$


Here is my list. The first column contains its index and second column has data.



list=1, 170.93, 2, 170.4, 3, 174.08, 4, 160.65, 5, 166.44, 6, 
169.75, 7, 175.86, 8, 177.6, 9, 180.27, 10, 182.82, 11,
182.02, 12, 186.65, 13, 184.53, 14, 186.17, 15,
177.29, 16, 172.06, 17, 175.58, 18, 168.09, 19,
172.33, 20, 165.1, 21, 154.88, 22, 161.28, 23, 165.25, 24,
165.15, 25, 171.03, 26, 174.55, 27, 182.57, 28,
191.02, 29, 191.11, 30, 184.93, 31, 188.85, 32, 191.44;


I want to delete all numbers that are smaller than the last largest element. For example, I want to delete 4th, 5th and 6th elements because they are smaller than the last largest element (3rd). Similarly, I want to delete elements from 13th to 27th elements because they are smaller than the last largest element (12th). 30th and 31st elements should be deleted because they are smaller than prior largest element (29th). Final results should contain increasing numbers. Here is the tabular representation of the data:



enter image description here



I did my best to explain my problem. Please write in the comment if it is not clear. I have a big data and I need to manipulate it as explained here. Any help would be greatly appreciated. Thanks










share|improve this question









$endgroup$







  • 4




    $begingroup$
    DeleteDuplicatesBy[ Transpose[list[[All, 1]], FoldList[Max, list[[All, 2]]]], Last] should do what you're after.
    $endgroup$
    – ciao
    8 hours ago










  • $begingroup$
    Should you also be deleting the second element since it is smaller than the first? I will note that the solution from @ciao does remove the second element.
    $endgroup$
    – Mark R
    7 hours ago











  • $begingroup$
    @ Mark R, yes you are right. I missed it. Thanks
    $endgroup$
    – DestinationLess_Traveller
    7 hours ago






  • 2




    $begingroup$
    DeleteDuplicates[list, #1[[2]] > #2[[2]] &]
    $endgroup$
    – Bob Hanlon
    7 hours ago










  • $begingroup$
    @ Bob, thanks for your simple answer. I really appreciate it.
    $endgroup$
    – DestinationLess_Traveller
    2 hours ago













3












3








3





$begingroup$


Here is my list. The first column contains its index and second column has data.



list=1, 170.93, 2, 170.4, 3, 174.08, 4, 160.65, 5, 166.44, 6, 
169.75, 7, 175.86, 8, 177.6, 9, 180.27, 10, 182.82, 11,
182.02, 12, 186.65, 13, 184.53, 14, 186.17, 15,
177.29, 16, 172.06, 17, 175.58, 18, 168.09, 19,
172.33, 20, 165.1, 21, 154.88, 22, 161.28, 23, 165.25, 24,
165.15, 25, 171.03, 26, 174.55, 27, 182.57, 28,
191.02, 29, 191.11, 30, 184.93, 31, 188.85, 32, 191.44;


I want to delete all numbers that are smaller than the last largest element. For example, I want to delete 4th, 5th and 6th elements because they are smaller than the last largest element (3rd). Similarly, I want to delete elements from 13th to 27th elements because they are smaller than the last largest element (12th). 30th and 31st elements should be deleted because they are smaller than prior largest element (29th). Final results should contain increasing numbers. Here is the tabular representation of the data:



enter image description here



I did my best to explain my problem. Please write in the comment if it is not clear. I have a big data and I need to manipulate it as explained here. Any help would be greatly appreciated. Thanks










share|improve this question









$endgroup$




Here is my list. The first column contains its index and second column has data.



list=1, 170.93, 2, 170.4, 3, 174.08, 4, 160.65, 5, 166.44, 6, 
169.75, 7, 175.86, 8, 177.6, 9, 180.27, 10, 182.82, 11,
182.02, 12, 186.65, 13, 184.53, 14, 186.17, 15,
177.29, 16, 172.06, 17, 175.58, 18, 168.09, 19,
172.33, 20, 165.1, 21, 154.88, 22, 161.28, 23, 165.25, 24,
165.15, 25, 171.03, 26, 174.55, 27, 182.57, 28,
191.02, 29, 191.11, 30, 184.93, 31, 188.85, 32, 191.44;


I want to delete all numbers that are smaller than the last largest element. For example, I want to delete 4th, 5th and 6th elements because they are smaller than the last largest element (3rd). Similarly, I want to delete elements from 13th to 27th elements because they are smaller than the last largest element (12th). 30th and 31st elements should be deleted because they are smaller than prior largest element (29th). Final results should contain increasing numbers. Here is the tabular representation of the data:



enter image description here



I did my best to explain my problem. Please write in the comment if it is not clear. I have a big data and I need to manipulate it as explained here. Any help would be greatly appreciated. Thanks







list-manipulation programming






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 8 hours ago









DestinationLess_TravellerDestinationLess_Traveller

1295 bronze badges




1295 bronze badges







  • 4




    $begingroup$
    DeleteDuplicatesBy[ Transpose[list[[All, 1]], FoldList[Max, list[[All, 2]]]], Last] should do what you're after.
    $endgroup$
    – ciao
    8 hours ago










  • $begingroup$
    Should you also be deleting the second element since it is smaller than the first? I will note that the solution from @ciao does remove the second element.
    $endgroup$
    – Mark R
    7 hours ago











  • $begingroup$
    @ Mark R, yes you are right. I missed it. Thanks
    $endgroup$
    – DestinationLess_Traveller
    7 hours ago






  • 2




    $begingroup$
    DeleteDuplicates[list, #1[[2]] > #2[[2]] &]
    $endgroup$
    – Bob Hanlon
    7 hours ago










  • $begingroup$
    @ Bob, thanks for your simple answer. I really appreciate it.
    $endgroup$
    – DestinationLess_Traveller
    2 hours ago












  • 4




    $begingroup$
    DeleteDuplicatesBy[ Transpose[list[[All, 1]], FoldList[Max, list[[All, 2]]]], Last] should do what you're after.
    $endgroup$
    – ciao
    8 hours ago










  • $begingroup$
    Should you also be deleting the second element since it is smaller than the first? I will note that the solution from @ciao does remove the second element.
    $endgroup$
    – Mark R
    7 hours ago











  • $begingroup$
    @ Mark R, yes you are right. I missed it. Thanks
    $endgroup$
    – DestinationLess_Traveller
    7 hours ago






  • 2




    $begingroup$
    DeleteDuplicates[list, #1[[2]] > #2[[2]] &]
    $endgroup$
    – Bob Hanlon
    7 hours ago










  • $begingroup$
    @ Bob, thanks for your simple answer. I really appreciate it.
    $endgroup$
    – DestinationLess_Traveller
    2 hours ago







4




4




$begingroup$
DeleteDuplicatesBy[ Transpose[list[[All, 1]], FoldList[Max, list[[All, 2]]]], Last] should do what you're after.
$endgroup$
– ciao
8 hours ago




$begingroup$
DeleteDuplicatesBy[ Transpose[list[[All, 1]], FoldList[Max, list[[All, 2]]]], Last] should do what you're after.
$endgroup$
– ciao
8 hours ago












$begingroup$
Should you also be deleting the second element since it is smaller than the first? I will note that the solution from @ciao does remove the second element.
$endgroup$
– Mark R
7 hours ago





$begingroup$
Should you also be deleting the second element since it is smaller than the first? I will note that the solution from @ciao does remove the second element.
$endgroup$
– Mark R
7 hours ago













$begingroup$
@ Mark R, yes you are right. I missed it. Thanks
$endgroup$
– DestinationLess_Traveller
7 hours ago




$begingroup$
@ Mark R, yes you are right. I missed it. Thanks
$endgroup$
– DestinationLess_Traveller
7 hours ago




2




2




$begingroup$
DeleteDuplicates[list, #1[[2]] > #2[[2]] &]
$endgroup$
– Bob Hanlon
7 hours ago




$begingroup$
DeleteDuplicates[list, #1[[2]] > #2[[2]] &]
$endgroup$
– Bob Hanlon
7 hours ago












$begingroup$
@ Bob, thanks for your simple answer. I really appreciate it.
$endgroup$
– DestinationLess_Traveller
2 hours ago




$begingroup$
@ Bob, thanks for your simple answer. I really appreciate it.
$endgroup$
– DestinationLess_Traveller
2 hours ago










1 Answer
1






active

oldest

votes


















4












$begingroup$

TakeList[list, Length /@ Split[FoldList[Max, list[[All, 2]]]]][[All, 1]]



1, 170.93, 3, 174.08, 7, 175.86, 8, 177.6, 9, 180.27, 10,
182.82, 12, 186.65, 28, 191.02, 29, 191.11, 32, 191.44




Also



max = list[[1, -1]];
Split[list, Or[Last[#2] < max, max = Last[#2]] &][[All, 1]]



same result




DeleteDuplicates[Join @@ FoldList[MaximalBy[Last] @* Append, First @ list, 
Rest @ list]]



same result




The first method is much faster.






share|improve this answer











$endgroup$












  • $begingroup$
    Thank you kglr.
    $endgroup$
    – DestinationLess_Traveller
    6 hours ago










  • $begingroup$
    @DestinationLess_Traveller, thank you for the accept.
    $endgroup$
    – kglr
    6 hours ago













Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f201662%2fdelete-elements-less-than-the-last-largest-element%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









4












$begingroup$

TakeList[list, Length /@ Split[FoldList[Max, list[[All, 2]]]]][[All, 1]]



1, 170.93, 3, 174.08, 7, 175.86, 8, 177.6, 9, 180.27, 10,
182.82, 12, 186.65, 28, 191.02, 29, 191.11, 32, 191.44




Also



max = list[[1, -1]];
Split[list, Or[Last[#2] < max, max = Last[#2]] &][[All, 1]]



same result




DeleteDuplicates[Join @@ FoldList[MaximalBy[Last] @* Append, First @ list, 
Rest @ list]]



same result




The first method is much faster.






share|improve this answer











$endgroup$












  • $begingroup$
    Thank you kglr.
    $endgroup$
    – DestinationLess_Traveller
    6 hours ago










  • $begingroup$
    @DestinationLess_Traveller, thank you for the accept.
    $endgroup$
    – kglr
    6 hours ago















4












$begingroup$

TakeList[list, Length /@ Split[FoldList[Max, list[[All, 2]]]]][[All, 1]]



1, 170.93, 3, 174.08, 7, 175.86, 8, 177.6, 9, 180.27, 10,
182.82, 12, 186.65, 28, 191.02, 29, 191.11, 32, 191.44




Also



max = list[[1, -1]];
Split[list, Or[Last[#2] < max, max = Last[#2]] &][[All, 1]]



same result




DeleteDuplicates[Join @@ FoldList[MaximalBy[Last] @* Append, First @ list, 
Rest @ list]]



same result




The first method is much faster.






share|improve this answer











$endgroup$












  • $begingroup$
    Thank you kglr.
    $endgroup$
    – DestinationLess_Traveller
    6 hours ago










  • $begingroup$
    @DestinationLess_Traveller, thank you for the accept.
    $endgroup$
    – kglr
    6 hours ago













4












4








4





$begingroup$

TakeList[list, Length /@ Split[FoldList[Max, list[[All, 2]]]]][[All, 1]]



1, 170.93, 3, 174.08, 7, 175.86, 8, 177.6, 9, 180.27, 10,
182.82, 12, 186.65, 28, 191.02, 29, 191.11, 32, 191.44




Also



max = list[[1, -1]];
Split[list, Or[Last[#2] < max, max = Last[#2]] &][[All, 1]]



same result




DeleteDuplicates[Join @@ FoldList[MaximalBy[Last] @* Append, First @ list, 
Rest @ list]]



same result




The first method is much faster.






share|improve this answer











$endgroup$



TakeList[list, Length /@ Split[FoldList[Max, list[[All, 2]]]]][[All, 1]]



1, 170.93, 3, 174.08, 7, 175.86, 8, 177.6, 9, 180.27, 10,
182.82, 12, 186.65, 28, 191.02, 29, 191.11, 32, 191.44




Also



max = list[[1, -1]];
Split[list, Or[Last[#2] < max, max = Last[#2]] &][[All, 1]]



same result




DeleteDuplicates[Join @@ FoldList[MaximalBy[Last] @* Append, First @ list, 
Rest @ list]]



same result




The first method is much faster.







share|improve this answer














share|improve this answer



share|improve this answer








edited 7 hours ago

























answered 8 hours ago









kglrkglr

203k10 gold badges232 silver badges463 bronze badges




203k10 gold badges232 silver badges463 bronze badges











  • $begingroup$
    Thank you kglr.
    $endgroup$
    – DestinationLess_Traveller
    6 hours ago










  • $begingroup$
    @DestinationLess_Traveller, thank you for the accept.
    $endgroup$
    – kglr
    6 hours ago
















  • $begingroup$
    Thank you kglr.
    $endgroup$
    – DestinationLess_Traveller
    6 hours ago










  • $begingroup$
    @DestinationLess_Traveller, thank you for the accept.
    $endgroup$
    – kglr
    6 hours ago















$begingroup$
Thank you kglr.
$endgroup$
– DestinationLess_Traveller
6 hours ago




$begingroup$
Thank you kglr.
$endgroup$
– DestinationLess_Traveller
6 hours ago












$begingroup$
@DestinationLess_Traveller, thank you for the accept.
$endgroup$
– kglr
6 hours ago




$begingroup$
@DestinationLess_Traveller, thank you for the accept.
$endgroup$
– kglr
6 hours ago

















draft saved

draft discarded
















































Thanks for contributing an answer to Mathematica Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f201662%2fdelete-elements-less-than-the-last-largest-element%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

ParseJSON using SSJSUsing AMPscript with SSJS ActivitiesHow to resubscribe a user in Marketing cloud using SSJS?Pulling Subscriber Status from Lists using SSJSRetrieving Emails using SSJSProblem in updating DE using SSJSUsing SSJS to send single email in Marketing CloudError adding EmailSendDefinition using SSJS

Кампала Садржај Географија Географија Историја Становништво Привреда Партнерски градови Референце Спољашње везе Мени за навигацију0°11′ СГШ; 32°20′ ИГД / 0.18° СГШ; 32.34° ИГД / 0.18; 32.340°11′ СГШ; 32°20′ ИГД / 0.18° СГШ; 32.34° ИГД / 0.18; 32.34МедијиПодациЗванични веб-сајту

19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу