Merging two rows with rounding their first elemntsEfficiently extracting an array subset given a separate arrayMerge two Matrices without DuplicatesHow to pair-up nearest elements from different listsHow to collect elements in one list with the constraints provided in a second listMatching list entries by two values, adding the thirdDuties of Threads accompanied by `#` or a Rule `->`From equality of a list's rows to summation over different elements of a matrixTotal function between two elements of sub_listsforward or backward IntegerDigits in pairs must yield different resultsHow to identify similar sublists in a list and visualize the clusters?
Why do academics prefer Mac/Linux?
What should I wear to go and sign an employment contract?
Why would company (decision makers) wait for someone to retire, rather than lay them off, when their role is no longer needed?
Was Tyrion always a poor strategist?
How to draw pentagram-like shape in Latex?
Working hours and productivity expectations for game artists and programmers
What technology would Dwarves need to forge titanium?
Will this series of events work to drown the Tarrasque?
Why would you put your input amplifier in front of your filtering for an ECG signal?
Save my secrets!
How did Arya not get burned in S8E05, "The Bells"?
Are there any crystals that are theoretically possible, but haven't yet been made?
Why is so much ransomware breakable?
How was the blinking terminal cursor invented?
Is it standard to have the first week's pay indefinitely withheld?
What do you call bracelets you wear around the legs?
What color to choose as "danger" if the main color of my app is red
I recently started my machine learning PhD and I have absolutely no idea what I'm doing
Largest memory peripheral for Sinclair ZX81?
how to create an executable file for an AppleScript?
Why use a retrograde orbit?
Failing students when it might cause them economic ruin
Who is frowning in the sentence "Daisy looked at Tom frowning"?
Parse a C++14 integer literal
Merging two rows with rounding their first elemnts
Efficiently extracting an array subset given a separate arrayMerge two Matrices without DuplicatesHow to pair-up nearest elements from different listsHow to collect elements in one list with the constraints provided in a second listMatching list entries by two values, adding the thirdDuties of Threads accompanied by `#` or a Rule `->`From equality of a list's rows to summation over different elements of a matrixTotal function between two elements of sub_listsforward or backward IntegerDigits in pairs must yield different resultsHow to identify similar sublists in a list and visualize the clusters?
$begingroup$
Mathematica shows my data in the below style:
lst=....
-0.410927, 11, 16, 12, 16, 15, 5, 15, 6,
-0.410927, 9, 14, 10, 14, 13, 7, 13, 8
.....
As I copy the first -0.410927
in another cell, I saw that it is really -0.41092720756334744
and for the second -0.410927
, I noticed that it is -0.4109272075633472
in fact. Regards to the other rows in the above and the below positions of these two shown rows, which are presented by ...., how I merge such two rows and have a result as
output=lst=....
-0.410927, 11, 16, 12, 16, 15, 5, 15, 6, 9, 14, 10, 14, 13, 7, 13, 8
.....
In fact, there is no any differences between two -0.410927
for more digits than 3
.
I have to apply this procedure for other rows considering this fact that all elements have just 3
digits for being important. For instance 1.34267
is not different from 1.34311
.
How can I help Mathematica to merge multi rows with very similar first elements. The similarity is gained after rounding values up to 3
digits.
list-manipulation
$endgroup$
add a comment |
$begingroup$
Mathematica shows my data in the below style:
lst=....
-0.410927, 11, 16, 12, 16, 15, 5, 15, 6,
-0.410927, 9, 14, 10, 14, 13, 7, 13, 8
.....
As I copy the first -0.410927
in another cell, I saw that it is really -0.41092720756334744
and for the second -0.410927
, I noticed that it is -0.4109272075633472
in fact. Regards to the other rows in the above and the below positions of these two shown rows, which are presented by ...., how I merge such two rows and have a result as
output=lst=....
-0.410927, 11, 16, 12, 16, 15, 5, 15, 6, 9, 14, 10, 14, 13, 7, 13, 8
.....
In fact, there is no any differences between two -0.410927
for more digits than 3
.
I have to apply this procedure for other rows considering this fact that all elements have just 3
digits for being important. For instance 1.34267
is not different from 1.34311
.
How can I help Mathematica to merge multi rows with very similar first elements. The similarity is gained after rounding values up to 3
digits.
list-manipulation
$endgroup$
add a comment |
$begingroup$
Mathematica shows my data in the below style:
lst=....
-0.410927, 11, 16, 12, 16, 15, 5, 15, 6,
-0.410927, 9, 14, 10, 14, 13, 7, 13, 8
.....
As I copy the first -0.410927
in another cell, I saw that it is really -0.41092720756334744
and for the second -0.410927
, I noticed that it is -0.4109272075633472
in fact. Regards to the other rows in the above and the below positions of these two shown rows, which are presented by ...., how I merge such two rows and have a result as
output=lst=....
-0.410927, 11, 16, 12, 16, 15, 5, 15, 6, 9, 14, 10, 14, 13, 7, 13, 8
.....
In fact, there is no any differences between two -0.410927
for more digits than 3
.
I have to apply this procedure for other rows considering this fact that all elements have just 3
digits for being important. For instance 1.34267
is not different from 1.34311
.
How can I help Mathematica to merge multi rows with very similar first elements. The similarity is gained after rounding values up to 3
digits.
list-manipulation
$endgroup$
Mathematica shows my data in the below style:
lst=....
-0.410927, 11, 16, 12, 16, 15, 5, 15, 6,
-0.410927, 9, 14, 10, 14, 13, 7, 13, 8
.....
As I copy the first -0.410927
in another cell, I saw that it is really -0.41092720756334744
and for the second -0.410927
, I noticed that it is -0.4109272075633472
in fact. Regards to the other rows in the above and the below positions of these two shown rows, which are presented by ...., how I merge such two rows and have a result as
output=lst=....
-0.410927, 11, 16, 12, 16, 15, 5, 15, 6, 9, 14, 10, 14, 13, 7, 13, 8
.....
In fact, there is no any differences between two -0.410927
for more digits than 3
.
I have to apply this procedure for other rows considering this fact that all elements have just 3
digits for being important. For instance 1.34267
is not different from 1.34311
.
How can I help Mathematica to merge multi rows with very similar first elements. The similarity is gained after rounding values up to 3
digits.
list-manipulation
list-manipulation
asked 9 hours ago
Inzo BabariaInzo Babaria
45229
45229
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
lst = -0.410927, 11, 16, 12, 16, 15, 5, 15, 6,
-0.41, 11, 16, 12, 16, 15, 5, 15, 6,
-0.45123, 11, 16, 12, 16, 15, 5, 15, 6,
-0.410927, 9, 14, 10, 14, 13, 7, 13, 8;
Values@GroupBy[lst, Round[First@#, .001] &, #[[1, 1]], Join @@ #[[All, 2]] &]
-0.410927, 11, 16, 12, 16, 15, 5, 15, 6, 9, 14, 10,
14, 13, 7, 13, 8,
-0.41, 11, 16, 12, 16, 15,
5, 15, 6,
-0.45123, 11, 16, 12, 16, 15, 5, 15,
6
Values@GroupBy[lst, Round[First@#, .01] &, #[[1, 1]], Join @@ #[[All, 2]] &]
-0.410927, 11, 16, 12, 16, 15, 5, 15, 6, 11, 16, 12,
16, 15, 5, 15, 6, 9, 14, 10, 14, 13, 7, 13,
8,
-0.45123, 11, 16, 12, 16, 15, 5, 15, 6
$endgroup$
1
$begingroup$
Thankxx so much. But a problem: once I write the result asgrouped[[1]]
I reach-0.410927, 11, 16, 12, 16, 15, 5, 15, 6, -0.410927, 9,14, 10, 14, 13, 7, 13, 8
this out put is not yet merged!
$endgroup$
– Inzo Babaria
9 hours ago
$begingroup$
@Inzo, please see the updated version.
$endgroup$
– kglr
9 hours ago
$begingroup$
Amazing and wonderful !!!
$endgroup$
– Inzo Babaria
7 hours ago
add a comment |
$begingroup$
lst=-0.410927,11,16,12,16,15,5,15,6,-0.41,11,16,12,16,15,5,15,6,-0.45123,11,16,12,16,15,5,15,6,-0.410927,9,14,10,14,13,7,13,8;
#[[1,1]],Flatten[#[[All,2]],1]&/@Values[GroupBy[lst,SetPrecision[#[[1]],3]&]]
-0.410927, 11, 16, 12, 16, 15, 5, 15, 6, 9, 14, 10,
14, 13, 7, 13, 8, -0.41, 11, 16, 12, 16, 15,
5, 15, 6, -0.45123, 11, 16, 12, 16, 15, 5, 15, 6
$endgroup$
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f198527%2fmerging-two-rows-with-rounding-their-first-elemnts%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
lst = -0.410927, 11, 16, 12, 16, 15, 5, 15, 6,
-0.41, 11, 16, 12, 16, 15, 5, 15, 6,
-0.45123, 11, 16, 12, 16, 15, 5, 15, 6,
-0.410927, 9, 14, 10, 14, 13, 7, 13, 8;
Values@GroupBy[lst, Round[First@#, .001] &, #[[1, 1]], Join @@ #[[All, 2]] &]
-0.410927, 11, 16, 12, 16, 15, 5, 15, 6, 9, 14, 10,
14, 13, 7, 13, 8,
-0.41, 11, 16, 12, 16, 15,
5, 15, 6,
-0.45123, 11, 16, 12, 16, 15, 5, 15,
6
Values@GroupBy[lst, Round[First@#, .01] &, #[[1, 1]], Join @@ #[[All, 2]] &]
-0.410927, 11, 16, 12, 16, 15, 5, 15, 6, 11, 16, 12,
16, 15, 5, 15, 6, 9, 14, 10, 14, 13, 7, 13,
8,
-0.45123, 11, 16, 12, 16, 15, 5, 15, 6
$endgroup$
1
$begingroup$
Thankxx so much. But a problem: once I write the result asgrouped[[1]]
I reach-0.410927, 11, 16, 12, 16, 15, 5, 15, 6, -0.410927, 9,14, 10, 14, 13, 7, 13, 8
this out put is not yet merged!
$endgroup$
– Inzo Babaria
9 hours ago
$begingroup$
@Inzo, please see the updated version.
$endgroup$
– kglr
9 hours ago
$begingroup$
Amazing and wonderful !!!
$endgroup$
– Inzo Babaria
7 hours ago
add a comment |
$begingroup$
lst = -0.410927, 11, 16, 12, 16, 15, 5, 15, 6,
-0.41, 11, 16, 12, 16, 15, 5, 15, 6,
-0.45123, 11, 16, 12, 16, 15, 5, 15, 6,
-0.410927, 9, 14, 10, 14, 13, 7, 13, 8;
Values@GroupBy[lst, Round[First@#, .001] &, #[[1, 1]], Join @@ #[[All, 2]] &]
-0.410927, 11, 16, 12, 16, 15, 5, 15, 6, 9, 14, 10,
14, 13, 7, 13, 8,
-0.41, 11, 16, 12, 16, 15,
5, 15, 6,
-0.45123, 11, 16, 12, 16, 15, 5, 15,
6
Values@GroupBy[lst, Round[First@#, .01] &, #[[1, 1]], Join @@ #[[All, 2]] &]
-0.410927, 11, 16, 12, 16, 15, 5, 15, 6, 11, 16, 12,
16, 15, 5, 15, 6, 9, 14, 10, 14, 13, 7, 13,
8,
-0.45123, 11, 16, 12, 16, 15, 5, 15, 6
$endgroup$
1
$begingroup$
Thankxx so much. But a problem: once I write the result asgrouped[[1]]
I reach-0.410927, 11, 16, 12, 16, 15, 5, 15, 6, -0.410927, 9,14, 10, 14, 13, 7, 13, 8
this out put is not yet merged!
$endgroup$
– Inzo Babaria
9 hours ago
$begingroup$
@Inzo, please see the updated version.
$endgroup$
– kglr
9 hours ago
$begingroup$
Amazing and wonderful !!!
$endgroup$
– Inzo Babaria
7 hours ago
add a comment |
$begingroup$
lst = -0.410927, 11, 16, 12, 16, 15, 5, 15, 6,
-0.41, 11, 16, 12, 16, 15, 5, 15, 6,
-0.45123, 11, 16, 12, 16, 15, 5, 15, 6,
-0.410927, 9, 14, 10, 14, 13, 7, 13, 8;
Values@GroupBy[lst, Round[First@#, .001] &, #[[1, 1]], Join @@ #[[All, 2]] &]
-0.410927, 11, 16, 12, 16, 15, 5, 15, 6, 9, 14, 10,
14, 13, 7, 13, 8,
-0.41, 11, 16, 12, 16, 15,
5, 15, 6,
-0.45123, 11, 16, 12, 16, 15, 5, 15,
6
Values@GroupBy[lst, Round[First@#, .01] &, #[[1, 1]], Join @@ #[[All, 2]] &]
-0.410927, 11, 16, 12, 16, 15, 5, 15, 6, 11, 16, 12,
16, 15, 5, 15, 6, 9, 14, 10, 14, 13, 7, 13,
8,
-0.45123, 11, 16, 12, 16, 15, 5, 15, 6
$endgroup$
lst = -0.410927, 11, 16, 12, 16, 15, 5, 15, 6,
-0.41, 11, 16, 12, 16, 15, 5, 15, 6,
-0.45123, 11, 16, 12, 16, 15, 5, 15, 6,
-0.410927, 9, 14, 10, 14, 13, 7, 13, 8;
Values@GroupBy[lst, Round[First@#, .001] &, #[[1, 1]], Join @@ #[[All, 2]] &]
-0.410927, 11, 16, 12, 16, 15, 5, 15, 6, 9, 14, 10,
14, 13, 7, 13, 8,
-0.41, 11, 16, 12, 16, 15,
5, 15, 6,
-0.45123, 11, 16, 12, 16, 15, 5, 15,
6
Values@GroupBy[lst, Round[First@#, .01] &, #[[1, 1]], Join @@ #[[All, 2]] &]
-0.410927, 11, 16, 12, 16, 15, 5, 15, 6, 11, 16, 12,
16, 15, 5, 15, 6, 9, 14, 10, 14, 13, 7, 13,
8,
-0.45123, 11, 16, 12, 16, 15, 5, 15, 6
edited 9 hours ago
answered 9 hours ago
kglrkglr
192k10214434
192k10214434
1
$begingroup$
Thankxx so much. But a problem: once I write the result asgrouped[[1]]
I reach-0.410927, 11, 16, 12, 16, 15, 5, 15, 6, -0.410927, 9,14, 10, 14, 13, 7, 13, 8
this out put is not yet merged!
$endgroup$
– Inzo Babaria
9 hours ago
$begingroup$
@Inzo, please see the updated version.
$endgroup$
– kglr
9 hours ago
$begingroup$
Amazing and wonderful !!!
$endgroup$
– Inzo Babaria
7 hours ago
add a comment |
1
$begingroup$
Thankxx so much. But a problem: once I write the result asgrouped[[1]]
I reach-0.410927, 11, 16, 12, 16, 15, 5, 15, 6, -0.410927, 9,14, 10, 14, 13, 7, 13, 8
this out put is not yet merged!
$endgroup$
– Inzo Babaria
9 hours ago
$begingroup$
@Inzo, please see the updated version.
$endgroup$
– kglr
9 hours ago
$begingroup$
Amazing and wonderful !!!
$endgroup$
– Inzo Babaria
7 hours ago
1
1
$begingroup$
Thankxx so much. But a problem: once I write the result as
grouped[[1]]
I reach -0.410927, 11, 16, 12, 16, 15, 5, 15, 6, -0.410927, 9,14, 10, 14, 13, 7, 13, 8
this out put is not yet merged!$endgroup$
– Inzo Babaria
9 hours ago
$begingroup$
Thankxx so much. But a problem: once I write the result as
grouped[[1]]
I reach -0.410927, 11, 16, 12, 16, 15, 5, 15, 6, -0.410927, 9,14, 10, 14, 13, 7, 13, 8
this out put is not yet merged!$endgroup$
– Inzo Babaria
9 hours ago
$begingroup$
@Inzo, please see the updated version.
$endgroup$
– kglr
9 hours ago
$begingroup$
@Inzo, please see the updated version.
$endgroup$
– kglr
9 hours ago
$begingroup$
Amazing and wonderful !!!
$endgroup$
– Inzo Babaria
7 hours ago
$begingroup$
Amazing and wonderful !!!
$endgroup$
– Inzo Babaria
7 hours ago
add a comment |
$begingroup$
lst=-0.410927,11,16,12,16,15,5,15,6,-0.41,11,16,12,16,15,5,15,6,-0.45123,11,16,12,16,15,5,15,6,-0.410927,9,14,10,14,13,7,13,8;
#[[1,1]],Flatten[#[[All,2]],1]&/@Values[GroupBy[lst,SetPrecision[#[[1]],3]&]]
-0.410927, 11, 16, 12, 16, 15, 5, 15, 6, 9, 14, 10,
14, 13, 7, 13, 8, -0.41, 11, 16, 12, 16, 15,
5, 15, 6, -0.45123, 11, 16, 12, 16, 15, 5, 15, 6
$endgroup$
add a comment |
$begingroup$
lst=-0.410927,11,16,12,16,15,5,15,6,-0.41,11,16,12,16,15,5,15,6,-0.45123,11,16,12,16,15,5,15,6,-0.410927,9,14,10,14,13,7,13,8;
#[[1,1]],Flatten[#[[All,2]],1]&/@Values[GroupBy[lst,SetPrecision[#[[1]],3]&]]
-0.410927, 11, 16, 12, 16, 15, 5, 15, 6, 9, 14, 10,
14, 13, 7, 13, 8, -0.41, 11, 16, 12, 16, 15,
5, 15, 6, -0.45123, 11, 16, 12, 16, 15, 5, 15, 6
$endgroup$
add a comment |
$begingroup$
lst=-0.410927,11,16,12,16,15,5,15,6,-0.41,11,16,12,16,15,5,15,6,-0.45123,11,16,12,16,15,5,15,6,-0.410927,9,14,10,14,13,7,13,8;
#[[1,1]],Flatten[#[[All,2]],1]&/@Values[GroupBy[lst,SetPrecision[#[[1]],3]&]]
-0.410927, 11, 16, 12, 16, 15, 5, 15, 6, 9, 14, 10,
14, 13, 7, 13, 8, -0.41, 11, 16, 12, 16, 15,
5, 15, 6, -0.45123, 11, 16, 12, 16, 15, 5, 15, 6
$endgroup$
lst=-0.410927,11,16,12,16,15,5,15,6,-0.41,11,16,12,16,15,5,15,6,-0.45123,11,16,12,16,15,5,15,6,-0.410927,9,14,10,14,13,7,13,8;
#[[1,1]],Flatten[#[[All,2]],1]&/@Values[GroupBy[lst,SetPrecision[#[[1]],3]&]]
-0.410927, 11, 16, 12, 16, 15, 5, 15, 6, 9, 14, 10,
14, 13, 7, 13, 8, -0.41, 11, 16, 12, 16, 15,
5, 15, 6, -0.45123, 11, 16, 12, 16, 15, 5, 15, 6
answered 9 hours ago
J42161217J42161217
5,280425
5,280425
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f198527%2fmerging-two-rows-with-rounding-their-first-elemnts%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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