Message Boards Message Boards

0
|
3270 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Get full expression out of a list

Posted 10 years ago

Hi guys, im quiet new to Mathematica and having a problem getting a satisfying result for my input.

i am trying to get one Element out of a List but failing to get the whole element. I tried using the Select operator to get the right result but it doesn't give me the whole expression back. Here is an extract of my list (which is in original much larger)

{{648, {2014, 1, 1}}, {{0., 76.}, {133644., 109.}, {270239., 
   127.}, {404791., 144.}, {541085., 162.}, {676764., 181.}, {813351.,
    200.}, {948583., 216.}, {1.08266*10^6, 231.}, {1.21484*10^6, 
   245.}, {1.34529*10^6, 257.}}}, {{649, {2014, 1, 1}}, {{0., 
   949.}, {3.2973*10^6, 1503.}, {6.60845*10^6, 1723.}, {9.89806*10^6, 
   1938.}, {1.32045*10^7, 2120.}, {1.64081*10^7, 
   2418.}, {1.97125*10^7, 2697.}, {2.30952*10^7, 
   2947.}, {2.64008*10^7, 3248.}, {2.97159*10^7, 
   3797.}, {3.29841*10^7, 4745.}}}, {{656, {2014, 3, 1}}, {{0., 
   734.}, {2.92444*10^6, 1230.}, {5.83113*10^6, 1400.}, {8.75093*10^6,
    1576.}, {1.16738*10^7, 1758.}, {1.45865*10^7, 
   1948.}, {1.75132*10^7, 2180.}, {2.04388*10^7, 2439.}, {2.3342*10^7,
    2716.}, {2.62651*10^7, 2934.}, {2.9005*10^7, 
   3448.}}}}

The very first Element shows the ID and the second one is the date for e.g.. (the first ID is 648, and date is 2014.1.1 in this list) after that there are the important data i need. I only want to search the ID number so the date is quite uninteresting. So in the end i would like to have something like this... i search for 648 and it gives me back

{{648, {2014, 1, 1}}, {{0., 76.}, {133644., 109.}, {270239., 127.}, {404791., 144.}, {541085., 162.}, {676764., 181.}, {813351., 200.}, {948583., 216.}, {1.0826610^6, 231.}, {1.2148410^6, 245.}, {1.34529*10^6, 257.}}}

i would appreciate every help i get :)

POSTED BY: Kuri Mon
2 Replies
Posted 10 years ago

Sorry about that! Next time i will do it better. I didn't know it would work like that. That was kind of simple.

Thank you very much

POSTED BY: Kuri Mon

Could you please read how to post code properly. Please also be careful when copy-pasting, I think you are missing the first { bracket. If you assign all your data to variable data, then Cases and patterns with _ would do the trick:

Cases[data, {{648, _}, _}]

I recommend looking carefully through all examples on Cases and tutorials: Finding Expressions That Match a Pattern.

POSTED BY: Vitaliy Kaurov
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract