Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #6006 > unrolled thread

How to combine 2 list

Started byJohn <john@datasharks.biz>
First post2011-10-29 11:24 +0000
Last post2011-11-03 08:53 +0000
Articles 5 — 5 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  How to combine 2 list John <john@datasharks.biz> - 2011-10-29 11:24 +0000
    Re: How to combine 2 list "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-10-30 09:25 +0000
    Re: How to combine 2 list "Dr. Wolfgang Hintze" <weh@snafu.de> - 2011-10-30 09:30 +0000
    Re: How to combine 2 list Armand Tamzarian <mike.honeychurch@gmail.com> - 2011-10-30 09:33 +0000
    Re: How to combine 2 list JasonE <ebaughjason@gmail.com> - 2011-11-03 08:53 +0000

#6006 — How to combine 2 list

FromJohn <john@datasharks.biz>
Date2011-10-29 11:24 +0000
SubjectHow to combine 2 list
Message-ID<j8gnpp$5h6$1@smc.vnet.net>
I have tried to find the answer on this, I am sure it has been asked before. Can anyone help?

I have 2 list:

cumlativeNetProfitLoss = Drop[FoldList[Plus, 0, listNetProfitLoss], 1]

{1.11, 2.07, 2.75, 3.49, 3.79, 10.2, 11.03, 19.84, 22.07, 23.29}

and

dateList = Reverse[dateNetProfitLoss[[All, 1]]]
{{2011, 8, 31}, {2011, 9, 2}, {2011, 9, 6}, {2011, 9, 20}, {2011, 9, 21}, {2011, 9, 22}, {2011, 9, 28}, {2011, 9, 30}, {2011, 10, 4}, {2011, 10, 10}}

  
  


How to I get:

{{{2011, 8, 31}, 1.11}, {{2011, 9, 2}, 2.07}, {{2011, 9, 6}, 2.75}, {{2011, 9, 20}, 3.49}, {{2011, 9, 21}, 3.79}, {{2011, 9, 22}, 10.2}, {{2011, 9, 28}, 11.03}, {{2011, 9, 30}, 19.84}, {{2011, 10, 4}, 22.07}, {{2011, 10, 10}, 23.29}}


Thanks in advance.

[toc] | [next] | [standalone]


#6022

From"Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com>
Date2011-10-30 09:25 +0000
Message-ID<j8j55s$f34$1@smc.vnet.net>
In reply to#6006
On Sat, 29 Oct 2011 12:24:41 +0100, John <john@datasharks.biz> wrote:

> I have tried to find the answer on this, I am sure it has been asked  
> before. Can anyone help?
>
> I have 2 list:
>
> cumlativeNetProfitLoss = Drop[FoldList[Plus, 0, listNetProfitLoss], 1]
>
> {1.11, 2.07, 2.75, 3.49, 3.79, 10.2, 11.03, 19.84, 22.07, 23.29}
>
> and
>
> dateList = Reverse[dateNetProfitLoss[[All, 1]]]
> {{2011, 8, 31}, {2011, 9, 2}, {2011, 9, 6}, {2011, 9, 20}, {2011, 9,  
> 21}, {2011, 9, 22}, {2011, 9, 28}, {2011, 9, 30}, {2011, 10, 4}, {2011,  
> 10, 10}}
>
> How to I get:
>
> {{{2011, 8, 31}, 1.11}, {{2011, 9, 2}, 2.07}, {{2011, 9, 6}, 2.75},  
> {{2011, 9, 20}, 3.49}, {{2011, 9, 21}, 3.79}, {{2011, 9, 22}, 10.2},  
> {{2011, 9, 28}, 11.03}, {{2011, 9, 30}, 19.84}, {{2011, 10, 4}, 22.07},  
> {{2011, 10, 10}, 23.29}}
>
> Thanks in advance.
>

Actually this was asked only a few weeks ago; the thread is archived at:

http://forums.wolfram.com/mathgroup/archive/2011/Oct/msg00349.html

To re-iterate, you could use either

Thread[{dateList, cumlativeNetProfitLoss}]

or

Transpose[{dateList, cumlativeNetProfitLoss}]

(among other possibilities) to obtain the desired result.

[toc] | [prev] | [next] | [standalone]


#6039

From"Dr. Wolfgang Hintze" <weh@snafu.de>
Date2011-10-30 09:30 +0000
Message-ID<j8j5gd$f85$1@smc.vnet.net>
In reply to#6006
You can use Transpose[]

In[13]:=
a = {1.11, 2.07, 2.75, 3.49, 3.79, 10.2, 11.03, 19.84,
22.07, 23.29};
b = {{2011, 8, 31}, {2011, 9, 2}, {2011, 9, 6},
{2011, 9, 20}, {2011, 9, 21}, {2011, 9, 22},
{2011, 9, 28}, {2011, 9, 30}, {2011, 10, 4},
{2011, 10, 10}};
In[15]:=
Transpose[{b, a}]
Out[15]=
{{{2011, 8, 31}, 1.11}, {{2011, 9, 2}, 2.07},
{{2011, 9, 6}, 2.75}, {{2011, 9, 20}, 3.49},
{{2011, 9, 21}, 3.79}, {{2011, 9, 22}, 10.2},
{{2011, 9, 28}, 11.03}, {{2011, 9, 30}, 19.84},
{{2011, 10, 4}, 22.07}, {{2011, 10, 10}, 23.29}}

--- Wolfgang



"John" <john@datasharks.biz> schrieb im Newsbeitrag 
news:j8gnpp$5h6$1@smc.vnet.net...
>I have tried to find the answer on this, I am sure it has been asked 
>before. Can anyone help?
>
> I have 2 list:
>
> cumlativeNetProfitLoss = Drop[FoldList[Plus, 0, listNetProfitLoss], 
> 1]
>
> {1.11, 2.07, 2.75, 3.49, 3.79, 10.2, 11.03, 19.84, 22.07, 23.29}
>
> and
>
> dateList = Reverse[dateNetProfitLoss[[All, 1]]]
> {{2011, 8, 31}, {2011, 9, 2}, {2011, 9, 6}, {2011, 9, 20}, {2011, 9, 
> 21}, {2011, 9, 22}, {2011, 9, 28}, {2011, 9, 30}, {2011, 10, 4}, 
> {2011, 10, 10}}
>
>
>
>
>
> How to I get:
>
> {{{2011, 8, 31}, 1.11}, {{2011, 9, 2}, 2.07}, {{2011, 9, 6}, 2.75}, 
> {{2011, 9, 20}, 3.49}, {{2011, 9, 21}, 3.79}, {{2011, 9, 22}, 10.2}, 
> {{2011, 9, 28}, 11.03}, {{2011, 9, 30}, 19.84}, {{2011, 10, 4}, 
> 22.07}, {{2011, 10, 10}, 23.29}}
>
>
> Thanks in advance.
> 

[toc] | [prev] | [next] | [standalone]


#6044

FromArmand Tamzarian <mike.honeychurch@gmail.com>
Date2011-10-30 09:33 +0000
Message-ID<j8j5l6$f9j$1@smc.vnet.net>
In reply to#6006
On Oct 29, 10:24 pm, John <j...@datasharks.biz> wrote:
> I have tried to find the answer on this, I am sure it has been asked before. Can anyone help?
>
> I have 2 list:
>
> cumlativeNetProfitLoss = Drop[FoldList[Plus, 0, listNetProfitLoss], 1]
>
> {1.11, 2.07, 2.75, 3.49, 3.79, 10.2, 11.03, 19.84, 22.07, 23.29}
>
> and
>
> dateList = Reverse[dateNetProfitLoss[[All, 1]]]
> {{2011, 8, 31}, {2011, 9, 2}, {2011, 9, 6}, {2011, 9, 20}, {2011, 9, 21}, {2011, 9, 22}, {2011, 9, 28}, {2011, 9, 30}, {2011, 10, 4}, {2011, 10, 10}}
>
> How to I get:
>
> {{{2011, 8, 31}, 1.11}, {{2011, 9, 2}, 2.07}, {{2011, 9, 6}, 2.75}, {{2011, 9, 20}, 3.49}, {{2011, 9, 21}, 3.79}, {{2011, 9, 22}, 10.2}, {{2011, 9, 28}, 11.03}, {{2011, 9, 30}, 19.84}, {{2011, 10, 4}, 22.07}, {{2011, 10, 10}, 23.29}}
>
> Thanks in advance.

Transpose[{dateList, cumlativeNetProfitLoss}]

Mike

[toc] | [prev] | [next] | [standalone]


#6146

FromJasonE <ebaughjason@gmail.com>
Date2011-11-03 08:53 +0000
Message-ID<j8tkq9$f1g$1@smc.vnet.net>
In reply to#6006
Here's my version:

In[67]:= Table[ { dateList [[i]], cumlativeNetProfitLoss [[i]] }, { i,
Length[dateList] } ]

Out[67]= {{{2011, 8, 31}, 1.11}, {{2011, 9, 2}, 2.07}, {{2011, 9, 6},
  2.75}, {{2011, 9, 20}, 3.49}, {{2011, 9, 21}, 3.79}, {{2011, 9, 22},
   10.2}, {{2011, 9, 28}, 11.03}, {{2011, 9, 30},
  19.84}, {{2011, 10, 4}, 22.07}, {{2011, 10, 10}, 23.29}}


Jason Ebaugh


>
> {1.11, 2.07, 2.75, 3.49, 3.79, 10.2, 11.03, 19.84, 22.07, 23.29}
>
> and
>
> dateList = Reverse[dateNetProfitLoss[[All, 1]]]
> {{2011, 8, 31}, {2011, 9, 2}, {2011, 9, 6}, {2011, 9, 20}, {2011, 9, 21}, {2011, 9, 22}, {2011, 9, 28}, {2011, 9, 30}, {2011, 10, 4}, {2011, 10, 10}}
>
> How to I get:
>
> {{{2011, 8, 31}, 1.11}, {{2011, 9, 2}, 2.07}, {{2011, 9, 6}, 2.75}, {{2011, 9, 20}, 3.49}, {{2011, 9, 21}, 3.79}, {{2011, 9, 22}, 10.2}, {{2011, 9, 28}, 11.03}, {{2011, 9, 30}, 19.84}, {{2011, 10, 4}, 22.07}, {{2011, 10, 10}, 23.29}}
>
> Thanks in advance.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web