Matrix vector operations in Python
up vote
0
down vote
favorite
I made a similar post here. Now I am trying to generalize what was done there for an entire matrix of numbers.
Specifically I want to do this:
dates =
dates.append(NDD_month[0])
for i in range(1,len(cpi)):
dates.append((dates[i-1] + 12 - number_of_payments[:i]) % 12)
print(dates)
where the number_of_payments
is a matrix of type <class 'list'>
.
Here is an example:
print(number_of_payments[:1])
is
[array([[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1]])]
After performing what I want then
print(dates[:1])
Should be
[array([[8, 8, 7, 7, 6, 5, 4, 4, 11, 10, 10, 8]])]
or something like that.
EDIT:
Here is an example of what my data looks like:
print(number_of_payments[:3])
This gives me this:
[
array(
[
[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1]
]),
array(
[
[0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0],
[1, 3, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0]
]),
array(
[
[0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0],
[0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 0, 2, 0, 2, 1, 1, 0, 2, 1, 0, 0]
])
]
print(NDD_month[:3])
Gives me
[8, 7, 11]
Now for the answer I want I want to do something like this that I did in my earlier post where I had
dates =
dates.append(NDD_month[0])
for i in range(1, len(first_payments)):
dates.append((dates[i-1] + 12 - first_payments[i-1]) % 12)
print(dates)
This gave me the correct output of
[8 8 7 7 6 5 4 4 11 10 10 8]
But now since I have the number_of_payments
being a matrix I need to apply the same logic to this larger data structure. Let me know if that is clear.
Edit 2:
Okay this is hard to explain so I am going to go step by step example, I have this data or matrix (number_of_payments) whatever it is in python:
[[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1],
[0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0],
[1, 3, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0]]
I have another list or vector called NDD_month, the first three elements are
[8, 7, 11]
Now for sake of simplicity lets say I just have the first row of number_of_payments i.e.
[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1]
Further for simplicity lets say I have just the first element of NDD_month so
8
Then to get the answer I seek I would do this that Aurora Wang provided a nice answer too which was this
first_payments = number_of_payments[:1]
first_payments = first_payments[0][0]
dates =
dates.append(NDD_month[0])
for i in range(1, len(first_payments)):
dates.append((dates[i-1] + 12 - first_payments[i-1]) % 12)
print(dates)
This gives me [8, 8, 7, 7, 6, 5, 4, 4, 11, 10, 10, 8]
.
Now I need to do the same thing but for each row in the matrix and each element in the NDD_month vector. I hope that makes it much more clear.
I was thinking this may work but again I am new to python and this does not work:
dates =
for i in range(1,len(NDD_month)):
dates.append(NDD_month[i-1])
for j in range(1, len(NDD_month)):
dates.append((dates[j-1] + 12 - number_of_payments[i-1][j-1]) % 12)
print(dates)
python list matrix
|
show 11 more comments
up vote
0
down vote
favorite
I made a similar post here. Now I am trying to generalize what was done there for an entire matrix of numbers.
Specifically I want to do this:
dates =
dates.append(NDD_month[0])
for i in range(1,len(cpi)):
dates.append((dates[i-1] + 12 - number_of_payments[:i]) % 12)
print(dates)
where the number_of_payments
is a matrix of type <class 'list'>
.
Here is an example:
print(number_of_payments[:1])
is
[array([[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1]])]
After performing what I want then
print(dates[:1])
Should be
[array([[8, 8, 7, 7, 6, 5, 4, 4, 11, 10, 10, 8]])]
or something like that.
EDIT:
Here is an example of what my data looks like:
print(number_of_payments[:3])
This gives me this:
[
array(
[
[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1]
]),
array(
[
[0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0],
[1, 3, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0]
]),
array(
[
[0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0],
[0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 0, 2, 0, 2, 1, 1, 0, 2, 1, 0, 0]
])
]
print(NDD_month[:3])
Gives me
[8, 7, 11]
Now for the answer I want I want to do something like this that I did in my earlier post where I had
dates =
dates.append(NDD_month[0])
for i in range(1, len(first_payments)):
dates.append((dates[i-1] + 12 - first_payments[i-1]) % 12)
print(dates)
This gave me the correct output of
[8 8 7 7 6 5 4 4 11 10 10 8]
But now since I have the number_of_payments
being a matrix I need to apply the same logic to this larger data structure. Let me know if that is clear.
Edit 2:
Okay this is hard to explain so I am going to go step by step example, I have this data or matrix (number_of_payments) whatever it is in python:
[[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1],
[0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0],
[1, 3, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0]]
I have another list or vector called NDD_month, the first three elements are
[8, 7, 11]
Now for sake of simplicity lets say I just have the first row of number_of_payments i.e.
[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1]
Further for simplicity lets say I have just the first element of NDD_month so
8
Then to get the answer I seek I would do this that Aurora Wang provided a nice answer too which was this
first_payments = number_of_payments[:1]
first_payments = first_payments[0][0]
dates =
dates.append(NDD_month[0])
for i in range(1, len(first_payments)):
dates.append((dates[i-1] + 12 - first_payments[i-1]) % 12)
print(dates)
This gives me [8, 8, 7, 7, 6, 5, 4, 4, 11, 10, 10, 8]
.
Now I need to do the same thing but for each row in the matrix and each element in the NDD_month vector. I hope that makes it much more clear.
I was thinking this may work but again I am new to python and this does not work:
dates =
for i in range(1,len(NDD_month)):
dates.append(NDD_month[i-1])
for j in range(1, len(NDD_month)):
dates.append((dates[j-1] + 12 - number_of_payments[i-1][j-1]) % 12)
print(dates)
python list matrix
You create a list just by doing.. Where is
cpi
defined?
– TheIncorrigible1
Nov 20 at 0:09
cpi is just a list with a certain length that I know is doing to be the same
– Snorrlaxxx
Nov 20 at 0:11
@TheIncorrigible1 If my question does not make sense please clarify I will provide an example
– Snorrlaxxx
Nov 20 at 0:11
Could you please edit your question to make it more clear? Can you also provide the full content ofnumber_of_payments
?
– Aurora Wang
Nov 20 at 0:13
Also, from your previous post I don't think you're accessing your list the way you intend to. When you donumber_of_payments[:i]
you'll get a subset of your list that goes from index0
to indexi
(what is not what your C++ code was doing).
– Aurora Wang
Nov 20 at 0:16
|
show 11 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I made a similar post here. Now I am trying to generalize what was done there for an entire matrix of numbers.
Specifically I want to do this:
dates =
dates.append(NDD_month[0])
for i in range(1,len(cpi)):
dates.append((dates[i-1] + 12 - number_of_payments[:i]) % 12)
print(dates)
where the number_of_payments
is a matrix of type <class 'list'>
.
Here is an example:
print(number_of_payments[:1])
is
[array([[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1]])]
After performing what I want then
print(dates[:1])
Should be
[array([[8, 8, 7, 7, 6, 5, 4, 4, 11, 10, 10, 8]])]
or something like that.
EDIT:
Here is an example of what my data looks like:
print(number_of_payments[:3])
This gives me this:
[
array(
[
[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1]
]),
array(
[
[0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0],
[1, 3, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0]
]),
array(
[
[0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0],
[0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 0, 2, 0, 2, 1, 1, 0, 2, 1, 0, 0]
])
]
print(NDD_month[:3])
Gives me
[8, 7, 11]
Now for the answer I want I want to do something like this that I did in my earlier post where I had
dates =
dates.append(NDD_month[0])
for i in range(1, len(first_payments)):
dates.append((dates[i-1] + 12 - first_payments[i-1]) % 12)
print(dates)
This gave me the correct output of
[8 8 7 7 6 5 4 4 11 10 10 8]
But now since I have the number_of_payments
being a matrix I need to apply the same logic to this larger data structure. Let me know if that is clear.
Edit 2:
Okay this is hard to explain so I am going to go step by step example, I have this data or matrix (number_of_payments) whatever it is in python:
[[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1],
[0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0],
[1, 3, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0]]
I have another list or vector called NDD_month, the first three elements are
[8, 7, 11]
Now for sake of simplicity lets say I just have the first row of number_of_payments i.e.
[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1]
Further for simplicity lets say I have just the first element of NDD_month so
8
Then to get the answer I seek I would do this that Aurora Wang provided a nice answer too which was this
first_payments = number_of_payments[:1]
first_payments = first_payments[0][0]
dates =
dates.append(NDD_month[0])
for i in range(1, len(first_payments)):
dates.append((dates[i-1] + 12 - first_payments[i-1]) % 12)
print(dates)
This gives me [8, 8, 7, 7, 6, 5, 4, 4, 11, 10, 10, 8]
.
Now I need to do the same thing but for each row in the matrix and each element in the NDD_month vector. I hope that makes it much more clear.
I was thinking this may work but again I am new to python and this does not work:
dates =
for i in range(1,len(NDD_month)):
dates.append(NDD_month[i-1])
for j in range(1, len(NDD_month)):
dates.append((dates[j-1] + 12 - number_of_payments[i-1][j-1]) % 12)
print(dates)
python list matrix
I made a similar post here. Now I am trying to generalize what was done there for an entire matrix of numbers.
Specifically I want to do this:
dates =
dates.append(NDD_month[0])
for i in range(1,len(cpi)):
dates.append((dates[i-1] + 12 - number_of_payments[:i]) % 12)
print(dates)
where the number_of_payments
is a matrix of type <class 'list'>
.
Here is an example:
print(number_of_payments[:1])
is
[array([[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1]])]
After performing what I want then
print(dates[:1])
Should be
[array([[8, 8, 7, 7, 6, 5, 4, 4, 11, 10, 10, 8]])]
or something like that.
EDIT:
Here is an example of what my data looks like:
print(number_of_payments[:3])
This gives me this:
[
array(
[
[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1]
]),
array(
[
[0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0],
[1, 3, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0]
]),
array(
[
[0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0],
[0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 0, 2, 0, 2, 1, 1, 0, 2, 1, 0, 0]
])
]
print(NDD_month[:3])
Gives me
[8, 7, 11]
Now for the answer I want I want to do something like this that I did in my earlier post where I had
dates =
dates.append(NDD_month[0])
for i in range(1, len(first_payments)):
dates.append((dates[i-1] + 12 - first_payments[i-1]) % 12)
print(dates)
This gave me the correct output of
[8 8 7 7 6 5 4 4 11 10 10 8]
But now since I have the number_of_payments
being a matrix I need to apply the same logic to this larger data structure. Let me know if that is clear.
Edit 2:
Okay this is hard to explain so I am going to go step by step example, I have this data or matrix (number_of_payments) whatever it is in python:
[[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1],
[0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0],
[1, 3, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0]]
I have another list or vector called NDD_month, the first three elements are
[8, 7, 11]
Now for sake of simplicity lets say I just have the first row of number_of_payments i.e.
[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1]
Further for simplicity lets say I have just the first element of NDD_month so
8
Then to get the answer I seek I would do this that Aurora Wang provided a nice answer too which was this
first_payments = number_of_payments[:1]
first_payments = first_payments[0][0]
dates =
dates.append(NDD_month[0])
for i in range(1, len(first_payments)):
dates.append((dates[i-1] + 12 - first_payments[i-1]) % 12)
print(dates)
This gives me [8, 8, 7, 7, 6, 5, 4, 4, 11, 10, 10, 8]
.
Now I need to do the same thing but for each row in the matrix and each element in the NDD_month vector. I hope that makes it much more clear.
I was thinking this may work but again I am new to python and this does not work:
dates =
for i in range(1,len(NDD_month)):
dates.append(NDD_month[i-1])
for j in range(1, len(NDD_month)):
dates.append((dates[j-1] + 12 - number_of_payments[i-1][j-1]) % 12)
print(dates)
python list matrix
python list matrix
edited Nov 20 at 0:36
asked Nov 20 at 0:06
Snorrlaxxx
13111
13111
You create a list just by doing.. Where is
cpi
defined?
– TheIncorrigible1
Nov 20 at 0:09
cpi is just a list with a certain length that I know is doing to be the same
– Snorrlaxxx
Nov 20 at 0:11
@TheIncorrigible1 If my question does not make sense please clarify I will provide an example
– Snorrlaxxx
Nov 20 at 0:11
Could you please edit your question to make it more clear? Can you also provide the full content ofnumber_of_payments
?
– Aurora Wang
Nov 20 at 0:13
Also, from your previous post I don't think you're accessing your list the way you intend to. When you donumber_of_payments[:i]
you'll get a subset of your list that goes from index0
to indexi
(what is not what your C++ code was doing).
– Aurora Wang
Nov 20 at 0:16
|
show 11 more comments
You create a list just by doing.. Where is
cpi
defined?
– TheIncorrigible1
Nov 20 at 0:09
cpi is just a list with a certain length that I know is doing to be the same
– Snorrlaxxx
Nov 20 at 0:11
@TheIncorrigible1 If my question does not make sense please clarify I will provide an example
– Snorrlaxxx
Nov 20 at 0:11
Could you please edit your question to make it more clear? Can you also provide the full content ofnumber_of_payments
?
– Aurora Wang
Nov 20 at 0:13
Also, from your previous post I don't think you're accessing your list the way you intend to. When you donumber_of_payments[:i]
you'll get a subset of your list that goes from index0
to indexi
(what is not what your C++ code was doing).
– Aurora Wang
Nov 20 at 0:16
You create a list just by doing
.. Where is cpi
defined?– TheIncorrigible1
Nov 20 at 0:09
You create a list just by doing
.. Where is cpi
defined?– TheIncorrigible1
Nov 20 at 0:09
cpi is just a list with a certain length that I know is doing to be the same
– Snorrlaxxx
Nov 20 at 0:11
cpi is just a list with a certain length that I know is doing to be the same
– Snorrlaxxx
Nov 20 at 0:11
@TheIncorrigible1 If my question does not make sense please clarify I will provide an example
– Snorrlaxxx
Nov 20 at 0:11
@TheIncorrigible1 If my question does not make sense please clarify I will provide an example
– Snorrlaxxx
Nov 20 at 0:11
Could you please edit your question to make it more clear? Can you also provide the full content of
number_of_payments
?– Aurora Wang
Nov 20 at 0:13
Could you please edit your question to make it more clear? Can you also provide the full content of
number_of_payments
?– Aurora Wang
Nov 20 at 0:13
Also, from your previous post I don't think you're accessing your list the way you intend to. When you do
number_of_payments[:i]
you'll get a subset of your list that goes from index 0
to index i
(what is not what your C++ code was doing).– Aurora Wang
Nov 20 at 0:16
Also, from your previous post I don't think you're accessing your list the way you intend to. When you do
number_of_payments[:i]
you'll get a subset of your list that goes from index 0
to index i
(what is not what your C++ code was doing).– Aurora Wang
Nov 20 at 0:16
|
show 11 more comments
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
If I understood you right, you want to do something like this:
number_of_payments = [
[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1],
[0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0],
[1, 3, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0]
]
NDD_month = [8, 7, 11]
dates =
for i in range(len(number_of_payments)):
dates.append([NDD_month[i]])
for j in range(1, len(number_of_payments[i])):
dates[i].append((dates[i][j-1] + 12 - number_of_payments[i][j-1]) % 12)
print(dates)
Yes that seems right but do you know how to convert the number_of_payments to be like that from how it is currently which is [array([[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1]]), array([[0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0], [1, 3, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0]]),
– Snorrlaxxx
Nov 20 at 0:49
Do you want to flatten your arrays into a list of lists?
– Aurora Wang
Nov 20 at 0:51
@Snorrlaxxx Are you using an external library?array()
is not built-in
– TheIncorrigible1
Nov 20 at 0:53
Actually I think your code works fine its just taking awhile to run since the len(number_of_payments) is 1346
– Snorrlaxxx
Nov 20 at 0:54
I got this: IOPub data rate exceeded. The notebook server will temporarily stop sending output to the client in order to avoid crashing it. To change this limit, set the config variable--NotebookApp.iopub_data_rate_limit
.
– Snorrlaxxx
Nov 20 at 0:54
|
show 10 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
If I understood you right, you want to do something like this:
number_of_payments = [
[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1],
[0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0],
[1, 3, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0]
]
NDD_month = [8, 7, 11]
dates =
for i in range(len(number_of_payments)):
dates.append([NDD_month[i]])
for j in range(1, len(number_of_payments[i])):
dates[i].append((dates[i][j-1] + 12 - number_of_payments[i][j-1]) % 12)
print(dates)
Yes that seems right but do you know how to convert the number_of_payments to be like that from how it is currently which is [array([[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1]]), array([[0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0], [1, 3, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0]]),
– Snorrlaxxx
Nov 20 at 0:49
Do you want to flatten your arrays into a list of lists?
– Aurora Wang
Nov 20 at 0:51
@Snorrlaxxx Are you using an external library?array()
is not built-in
– TheIncorrigible1
Nov 20 at 0:53
Actually I think your code works fine its just taking awhile to run since the len(number_of_payments) is 1346
– Snorrlaxxx
Nov 20 at 0:54
I got this: IOPub data rate exceeded. The notebook server will temporarily stop sending output to the client in order to avoid crashing it. To change this limit, set the config variable--NotebookApp.iopub_data_rate_limit
.
– Snorrlaxxx
Nov 20 at 0:54
|
show 10 more comments
up vote
1
down vote
accepted
If I understood you right, you want to do something like this:
number_of_payments = [
[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1],
[0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0],
[1, 3, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0]
]
NDD_month = [8, 7, 11]
dates =
for i in range(len(number_of_payments)):
dates.append([NDD_month[i]])
for j in range(1, len(number_of_payments[i])):
dates[i].append((dates[i][j-1] + 12 - number_of_payments[i][j-1]) % 12)
print(dates)
Yes that seems right but do you know how to convert the number_of_payments to be like that from how it is currently which is [array([[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1]]), array([[0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0], [1, 3, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0]]),
– Snorrlaxxx
Nov 20 at 0:49
Do you want to flatten your arrays into a list of lists?
– Aurora Wang
Nov 20 at 0:51
@Snorrlaxxx Are you using an external library?array()
is not built-in
– TheIncorrigible1
Nov 20 at 0:53
Actually I think your code works fine its just taking awhile to run since the len(number_of_payments) is 1346
– Snorrlaxxx
Nov 20 at 0:54
I got this: IOPub data rate exceeded. The notebook server will temporarily stop sending output to the client in order to avoid crashing it. To change this limit, set the config variable--NotebookApp.iopub_data_rate_limit
.
– Snorrlaxxx
Nov 20 at 0:54
|
show 10 more comments
up vote
1
down vote
accepted
up vote
1
down vote
accepted
If I understood you right, you want to do something like this:
number_of_payments = [
[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1],
[0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0],
[1, 3, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0]
]
NDD_month = [8, 7, 11]
dates =
for i in range(len(number_of_payments)):
dates.append([NDD_month[i]])
for j in range(1, len(number_of_payments[i])):
dates[i].append((dates[i][j-1] + 12 - number_of_payments[i][j-1]) % 12)
print(dates)
If I understood you right, you want to do something like this:
number_of_payments = [
[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1],
[0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0],
[1, 3, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0]
]
NDD_month = [8, 7, 11]
dates =
for i in range(len(number_of_payments)):
dates.append([NDD_month[i]])
for j in range(1, len(number_of_payments[i])):
dates[i].append((dates[i][j-1] + 12 - number_of_payments[i][j-1]) % 12)
print(dates)
answered Nov 20 at 0:47
Aurora Wang
509112
509112
Yes that seems right but do you know how to convert the number_of_payments to be like that from how it is currently which is [array([[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1]]), array([[0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0], [1, 3, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0]]),
– Snorrlaxxx
Nov 20 at 0:49
Do you want to flatten your arrays into a list of lists?
– Aurora Wang
Nov 20 at 0:51
@Snorrlaxxx Are you using an external library?array()
is not built-in
– TheIncorrigible1
Nov 20 at 0:53
Actually I think your code works fine its just taking awhile to run since the len(number_of_payments) is 1346
– Snorrlaxxx
Nov 20 at 0:54
I got this: IOPub data rate exceeded. The notebook server will temporarily stop sending output to the client in order to avoid crashing it. To change this limit, set the config variable--NotebookApp.iopub_data_rate_limit
.
– Snorrlaxxx
Nov 20 at 0:54
|
show 10 more comments
Yes that seems right but do you know how to convert the number_of_payments to be like that from how it is currently which is [array([[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1]]), array([[0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0], [1, 3, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0]]),
– Snorrlaxxx
Nov 20 at 0:49
Do you want to flatten your arrays into a list of lists?
– Aurora Wang
Nov 20 at 0:51
@Snorrlaxxx Are you using an external library?array()
is not built-in
– TheIncorrigible1
Nov 20 at 0:53
Actually I think your code works fine its just taking awhile to run since the len(number_of_payments) is 1346
– Snorrlaxxx
Nov 20 at 0:54
I got this: IOPub data rate exceeded. The notebook server will temporarily stop sending output to the client in order to avoid crashing it. To change this limit, set the config variable--NotebookApp.iopub_data_rate_limit
.
– Snorrlaxxx
Nov 20 at 0:54
Yes that seems right but do you know how to convert the number_of_payments to be like that from how it is currently which is [array([[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1]]), array([[0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0], [1, 3, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0]]),
– Snorrlaxxx
Nov 20 at 0:49
Yes that seems right but do you know how to convert the number_of_payments to be like that from how it is currently which is [array([[0, 1, 0, 1, 1, 1, 0, 5, 1, 0, 2, 1]]), array([[0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0], [1, 3, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0]]),
– Snorrlaxxx
Nov 20 at 0:49
Do you want to flatten your arrays into a list of lists?
– Aurora Wang
Nov 20 at 0:51
Do you want to flatten your arrays into a list of lists?
– Aurora Wang
Nov 20 at 0:51
@Snorrlaxxx Are you using an external library?
array()
is not built-in– TheIncorrigible1
Nov 20 at 0:53
@Snorrlaxxx Are you using an external library?
array()
is not built-in– TheIncorrigible1
Nov 20 at 0:53
Actually I think your code works fine its just taking awhile to run since the len(number_of_payments) is 1346
– Snorrlaxxx
Nov 20 at 0:54
Actually I think your code works fine its just taking awhile to run since the len(number_of_payments) is 1346
– Snorrlaxxx
Nov 20 at 0:54
I got this: IOPub data rate exceeded. The notebook server will temporarily stop sending output to the client in order to avoid crashing it. To change this limit, set the config variable
--NotebookApp.iopub_data_rate_limit
.– Snorrlaxxx
Nov 20 at 0:54
I got this: IOPub data rate exceeded. The notebook server will temporarily stop sending output to the client in order to avoid crashing it. To change this limit, set the config variable
--NotebookApp.iopub_data_rate_limit
.– Snorrlaxxx
Nov 20 at 0:54
|
show 10 more comments
Thanks for contributing an answer to Stack Overflow!
- 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.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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.
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%2fstackoverflow.com%2fquestions%2f53384396%2fmatrix-vector-operations-in-python%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
You create a list just by doing
.. Where is
cpi
defined?– TheIncorrigible1
Nov 20 at 0:09
cpi is just a list with a certain length that I know is doing to be the same
– Snorrlaxxx
Nov 20 at 0:11
@TheIncorrigible1 If my question does not make sense please clarify I will provide an example
– Snorrlaxxx
Nov 20 at 0:11
Could you please edit your question to make it more clear? Can you also provide the full content of
number_of_payments
?– Aurora Wang
Nov 20 at 0:13
Also, from your previous post I don't think you're accessing your list the way you intend to. When you do
number_of_payments[:i]
you'll get a subset of your list that goes from index0
to indexi
(what is not what your C++ code was doing).– Aurora Wang
Nov 20 at 0:16