Dimension change when removing element
Clash Royale CLAN TAG#URR8PPP
up vote
5
down vote
favorite
I have a list of 3d coordinates.
data = 1., 2., 3., 2., 3., 4., 4., 5., 6., 6., 7., 8., 8.,
9., 10.;
Dimensions[data]
data[[All, 2]] = data[[All, 2]]*0;
data
Dimensions[data]
data = DeleteCases[data, 0., 2]
Dimensions[data]
5, 3
1., 0., 3., 2., 0., 4., 4., 0., 6., 6., 0., 8., 8., 0., 10.
5, 3
1., 3., 2., 4., 4., 6., 6., 8., 8., 10.
5, 2
The code abode does as expected it reduces the dimensions from 5,3->5,2
I tried the same code on a larger array, dimensions then go from 11698,3 -> 11698. The elements are still x,z if one calls LargeArray[[1]]
one get a list of two elements. However mathematica treats its as on entity. This causes the data to not be interpreted right in a ListPLot
call. Any thought on why this is happening?
plotting list-manipulation
add a comment |Â
up vote
5
down vote
favorite
I have a list of 3d coordinates.
data = 1., 2., 3., 2., 3., 4., 4., 5., 6., 6., 7., 8., 8.,
9., 10.;
Dimensions[data]
data[[All, 2]] = data[[All, 2]]*0;
data
Dimensions[data]
data = DeleteCases[data, 0., 2]
Dimensions[data]
5, 3
1., 0., 3., 2., 0., 4., 4., 0., 6., 6., 0., 8., 8., 0., 10.
5, 3
1., 3., 2., 4., 4., 6., 6., 8., 8., 10.
5, 2
The code abode does as expected it reduces the dimensions from 5,3->5,2
I tried the same code on a larger array, dimensions then go from 11698,3 -> 11698. The elements are still x,z if one calls LargeArray[[1]]
one get a list of two elements. However mathematica treats its as on entity. This causes the data to not be interpreted right in a ListPLot
call. Any thought on why this is happening?
plotting list-manipulation
I'm guessing that the array became ragged and not all sublists have the same length any more. E.g.,Dimensions[1, 2, 1, 1, 3] === 3
. TryCounts[Length /@ LargeArray]
and see how many different lengths there are in your array.
– Sjoerd Smit
23 hours ago
That actually might be it, I didnt take into account that if either x or z is 0. it get deleted creating list with just one or zero elements.
– Giovanni Baez
23 hours ago
add a comment |Â
up vote
5
down vote
favorite
up vote
5
down vote
favorite
I have a list of 3d coordinates.
data = 1., 2., 3., 2., 3., 4., 4., 5., 6., 6., 7., 8., 8.,
9., 10.;
Dimensions[data]
data[[All, 2]] = data[[All, 2]]*0;
data
Dimensions[data]
data = DeleteCases[data, 0., 2]
Dimensions[data]
5, 3
1., 0., 3., 2., 0., 4., 4., 0., 6., 6., 0., 8., 8., 0., 10.
5, 3
1., 3., 2., 4., 4., 6., 6., 8., 8., 10.
5, 2
The code abode does as expected it reduces the dimensions from 5,3->5,2
I tried the same code on a larger array, dimensions then go from 11698,3 -> 11698. The elements are still x,z if one calls LargeArray[[1]]
one get a list of two elements. However mathematica treats its as on entity. This causes the data to not be interpreted right in a ListPLot
call. Any thought on why this is happening?
plotting list-manipulation
I have a list of 3d coordinates.
data = 1., 2., 3., 2., 3., 4., 4., 5., 6., 6., 7., 8., 8.,
9., 10.;
Dimensions[data]
data[[All, 2]] = data[[All, 2]]*0;
data
Dimensions[data]
data = DeleteCases[data, 0., 2]
Dimensions[data]
5, 3
1., 0., 3., 2., 0., 4., 4., 0., 6., 6., 0., 8., 8., 0., 10.
5, 3
1., 3., 2., 4., 4., 6., 6., 8., 8., 10.
5, 2
The code abode does as expected it reduces the dimensions from 5,3->5,2
I tried the same code on a larger array, dimensions then go from 11698,3 -> 11698. The elements are still x,z if one calls LargeArray[[1]]
one get a list of two elements. However mathematica treats its as on entity. This causes the data to not be interpreted right in a ListPLot
call. Any thought on why this is happening?
plotting list-manipulation
plotting list-manipulation
asked 23 hours ago


Giovanni Baez
424111
424111
I'm guessing that the array became ragged and not all sublists have the same length any more. E.g.,Dimensions[1, 2, 1, 1, 3] === 3
. TryCounts[Length /@ LargeArray]
and see how many different lengths there are in your array.
– Sjoerd Smit
23 hours ago
That actually might be it, I didnt take into account that if either x or z is 0. it get deleted creating list with just one or zero elements.
– Giovanni Baez
23 hours ago
add a comment |Â
I'm guessing that the array became ragged and not all sublists have the same length any more. E.g.,Dimensions[1, 2, 1, 1, 3] === 3
. TryCounts[Length /@ LargeArray]
and see how many different lengths there are in your array.
– Sjoerd Smit
23 hours ago
That actually might be it, I didnt take into account that if either x or z is 0. it get deleted creating list with just one or zero elements.
– Giovanni Baez
23 hours ago
I'm guessing that the array became ragged and not all sublists have the same length any more. E.g.,
Dimensions[1, 2, 1, 1, 3] === 3
. Try Counts[Length /@ LargeArray]
and see how many different lengths there are in your array.– Sjoerd Smit
23 hours ago
I'm guessing that the array became ragged and not all sublists have the same length any more. E.g.,
Dimensions[1, 2, 1, 1, 3] === 3
. Try Counts[Length /@ LargeArray]
and see how many different lengths there are in your array.– Sjoerd Smit
23 hours ago
That actually might be it, I didnt take into account that if either x or z is 0. it get deleted creating list with just one or zero elements.
– Giovanni Baez
23 hours ago
That actually might be it, I didnt take into account that if either x or z is 0. it get deleted creating list with just one or zero elements.
– Giovanni Baez
23 hours ago
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
5
down vote
accepted
I take it you are trying to plot the (x,z) coordinates against one another?
It is safer to delete the (y) coordinates than replacing them with zeros and deleting zeros. If there are any other zeros in the data you will get undesired results. I suspect this is the case, since your data's new shape is only 116908 (meaning not all entries are the same length).
Instead, you could take only the first and last column like:
data[[All, 1, 3]]
New contributor
Tyler Chen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
That was exactly what was happening. Thanks Tyler.
– Giovanni Baez
23 hours ago
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
I take it you are trying to plot the (x,z) coordinates against one another?
It is safer to delete the (y) coordinates than replacing them with zeros and deleting zeros. If there are any other zeros in the data you will get undesired results. I suspect this is the case, since your data's new shape is only 116908 (meaning not all entries are the same length).
Instead, you could take only the first and last column like:
data[[All, 1, 3]]
New contributor
Tyler Chen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
That was exactly what was happening. Thanks Tyler.
– Giovanni Baez
23 hours ago
add a comment |Â
up vote
5
down vote
accepted
I take it you are trying to plot the (x,z) coordinates against one another?
It is safer to delete the (y) coordinates than replacing them with zeros and deleting zeros. If there are any other zeros in the data you will get undesired results. I suspect this is the case, since your data's new shape is only 116908 (meaning not all entries are the same length).
Instead, you could take only the first and last column like:
data[[All, 1, 3]]
New contributor
Tyler Chen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
That was exactly what was happening. Thanks Tyler.
– Giovanni Baez
23 hours ago
add a comment |Â
up vote
5
down vote
accepted
up vote
5
down vote
accepted
I take it you are trying to plot the (x,z) coordinates against one another?
It is safer to delete the (y) coordinates than replacing them with zeros and deleting zeros. If there are any other zeros in the data you will get undesired results. I suspect this is the case, since your data's new shape is only 116908 (meaning not all entries are the same length).
Instead, you could take only the first and last column like:
data[[All, 1, 3]]
New contributor
Tyler Chen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I take it you are trying to plot the (x,z) coordinates against one another?
It is safer to delete the (y) coordinates than replacing them with zeros and deleting zeros. If there are any other zeros in the data you will get undesired results. I suspect this is the case, since your data's new shape is only 116908 (meaning not all entries are the same length).
Instead, you could take only the first and last column like:
data[[All, 1, 3]]
New contributor
Tyler Chen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Tyler Chen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 23 hours ago
Tyler Chen
1664
1664
New contributor
Tyler Chen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Tyler Chen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Tyler Chen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
That was exactly what was happening. Thanks Tyler.
– Giovanni Baez
23 hours ago
add a comment |Â
2
That was exactly what was happening. Thanks Tyler.
– Giovanni Baez
23 hours ago
2
2
That was exactly what was happening. Thanks Tyler.
– Giovanni Baez
23 hours ago
That was exactly what was happening. Thanks Tyler.
– Giovanni Baez
23 hours ago
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f181764%2fdimension-change-when-removing-element%23new-answer', 'question_page');
);
Post as a guest
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
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
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
I'm guessing that the array became ragged and not all sublists have the same length any more. E.g.,
Dimensions[1, 2, 1, 1, 3] === 3
. TryCounts[Length /@ LargeArray]
and see how many different lengths there are in your array.– Sjoerd Smit
23 hours ago
That actually might be it, I didnt take into account that if either x or z is 0. it get deleted creating list with just one or zero elements.
– Giovanni Baez
23 hours ago