Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #6006 > unrolled thread
| Started by | John <john@datasharks.biz> |
|---|---|
| First post | 2011-10-29 11:24 +0000 |
| Last post | 2011-11-03 08:53 +0000 |
| Articles | 5 — 5 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
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
| From | John <john@datasharks.biz> |
|---|---|
| Date | 2011-10-29 11:24 +0000 |
| Subject | How 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]
| From | "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> |
|---|---|
| Date | 2011-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]
| From | "Dr. Wolfgang Hintze" <weh@snafu.de> |
|---|---|
| Date | 2011-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]
| From | Armand Tamzarian <mike.honeychurch@gmail.com> |
|---|---|
| Date | 2011-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]
| From | JasonE <ebaughjason@gmail.com> |
|---|---|
| Date | 2011-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