How to remove from the data the rows of with fixed number of elements? [on hold]
$begingroup$
Consider the data which has the form
data = {{x1,y1,z1},{x2,y2,z2,t2},{x3,y4,z4,t4},{x5,y5,z5},...}
How to remove the rows containing three elements from the data?
I.e., to obtain
dataprime = {{x2,y2,z2,t2},{x3,y4,z4,t4},...}
list-manipulation filtering
$endgroup$
put on hold as off-topic by MarcoB, LCarvalho, Henrik Schumacher, J. M. is computer-less♦ 1 hour ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, LCarvalho, Henrik Schumacher, J. M. is computer-less
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
$begingroup$
Consider the data which has the form
data = {{x1,y1,z1},{x2,y2,z2,t2},{x3,y4,z4,t4},{x5,y5,z5},...}
How to remove the rows containing three elements from the data?
I.e., to obtain
dataprime = {{x2,y2,z2,t2},{x3,y4,z4,t4},...}
list-manipulation filtering
$endgroup$
put on hold as off-topic by MarcoB, LCarvalho, Henrik Schumacher, J. M. is computer-less♦ 1 hour ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, LCarvalho, Henrik Schumacher, J. M. is computer-less
If this question can be reworded to fit the rules in the help center, please edit the question.
1
$begingroup$
Maybe you ask forDeleteCases[data, _?(Length[#] == 3 &)]
...
$endgroup$
– Henrik Schumacher
11 hours ago
$begingroup$
@HenrikSchumacher : sorry, already corrected this.
$endgroup$
– John Taylor
11 hours ago
add a comment |
$begingroup$
Consider the data which has the form
data = {{x1,y1,z1},{x2,y2,z2,t2},{x3,y4,z4,t4},{x5,y5,z5},...}
How to remove the rows containing three elements from the data?
I.e., to obtain
dataprime = {{x2,y2,z2,t2},{x3,y4,z4,t4},...}
list-manipulation filtering
$endgroup$
Consider the data which has the form
data = {{x1,y1,z1},{x2,y2,z2,t2},{x3,y4,z4,t4},{x5,y5,z5},...}
How to remove the rows containing three elements from the data?
I.e., to obtain
dataprime = {{x2,y2,z2,t2},{x3,y4,z4,t4},...}
list-manipulation filtering
list-manipulation filtering
edited 1 hour ago
J. M. is computer-less♦
97k10303463
97k10303463
asked 11 hours ago
John TaylorJohn Taylor
736211
736211
put on hold as off-topic by MarcoB, LCarvalho, Henrik Schumacher, J. M. is computer-less♦ 1 hour ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, LCarvalho, Henrik Schumacher, J. M. is computer-less
If this question can be reworded to fit the rules in the help center, please edit the question.
put on hold as off-topic by MarcoB, LCarvalho, Henrik Schumacher, J. M. is computer-less♦ 1 hour ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, LCarvalho, Henrik Schumacher, J. M. is computer-less
If this question can be reworded to fit the rules in the help center, please edit the question.
1
$begingroup$
Maybe you ask forDeleteCases[data, _?(Length[#] == 3 &)]
...
$endgroup$
– Henrik Schumacher
11 hours ago
$begingroup$
@HenrikSchumacher : sorry, already corrected this.
$endgroup$
– John Taylor
11 hours ago
add a comment |
1
$begingroup$
Maybe you ask forDeleteCases[data, _?(Length[#] == 3 &)]
...
$endgroup$
– Henrik Schumacher
11 hours ago
$begingroup$
@HenrikSchumacher : sorry, already corrected this.
$endgroup$
– John Taylor
11 hours ago
1
1
$begingroup$
Maybe you ask for
DeleteCases[data, _?(Length[#] == 3 &)]
...$endgroup$
– Henrik Schumacher
11 hours ago
$begingroup$
Maybe you ask for
DeleteCases[data, _?(Length[#] == 3 &)]
...$endgroup$
– Henrik Schumacher
11 hours ago
$begingroup$
@HenrikSchumacher : sorry, already corrected this.
$endgroup$
– John Taylor
11 hours ago
$begingroup$
@HenrikSchumacher : sorry, already corrected this.
$endgroup$
– John Taylor
11 hours ago
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
Any one of these would do:
Cases[data, Except[_?(Length[#] == 3 &)]]
DeleteCases[data, _?(Length[#] == 3 &)]
Select[data, Length[#] != 3 &]
Delete[data, Position[data, _?(Length[#] == 3 &)]]
data /. {_, _, _} -> Nothing
data /. {Repeated[_, {3}]} -> Nothing
They all return: {{x2, y2, z2, t2}, {x3, y4, z4, t4}}
$endgroup$
add a comment |
$begingroup$
Also
Pick[data, Unitize[-3 + Length /@ data], 1]
$endgroup$
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Any one of these would do:
Cases[data, Except[_?(Length[#] == 3 &)]]
DeleteCases[data, _?(Length[#] == 3 &)]
Select[data, Length[#] != 3 &]
Delete[data, Position[data, _?(Length[#] == 3 &)]]
data /. {_, _, _} -> Nothing
data /. {Repeated[_, {3}]} -> Nothing
They all return: {{x2, y2, z2, t2}, {x3, y4, z4, t4}}
$endgroup$
add a comment |
$begingroup$
Any one of these would do:
Cases[data, Except[_?(Length[#] == 3 &)]]
DeleteCases[data, _?(Length[#] == 3 &)]
Select[data, Length[#] != 3 &]
Delete[data, Position[data, _?(Length[#] == 3 &)]]
data /. {_, _, _} -> Nothing
data /. {Repeated[_, {3}]} -> Nothing
They all return: {{x2, y2, z2, t2}, {x3, y4, z4, t4}}
$endgroup$
add a comment |
$begingroup$
Any one of these would do:
Cases[data, Except[_?(Length[#] == 3 &)]]
DeleteCases[data, _?(Length[#] == 3 &)]
Select[data, Length[#] != 3 &]
Delete[data, Position[data, _?(Length[#] == 3 &)]]
data /. {_, _, _} -> Nothing
data /. {Repeated[_, {3}]} -> Nothing
They all return: {{x2, y2, z2, t2}, {x3, y4, z4, t4}}
$endgroup$
Any one of these would do:
Cases[data, Except[_?(Length[#] == 3 &)]]
DeleteCases[data, _?(Length[#] == 3 &)]
Select[data, Length[#] != 3 &]
Delete[data, Position[data, _?(Length[#] == 3 &)]]
data /. {_, _, _} -> Nothing
data /. {Repeated[_, {3}]} -> Nothing
They all return: {{x2, y2, z2, t2}, {x3, y4, z4, t4}}
edited 10 hours ago
answered 11 hours ago
MarcoBMarcoB
36.3k556112
36.3k556112
add a comment |
add a comment |
$begingroup$
Also
Pick[data, Unitize[-3 + Length /@ data], 1]
$endgroup$
add a comment |
$begingroup$
Also
Pick[data, Unitize[-3 + Length /@ data], 1]
$endgroup$
add a comment |
$begingroup$
Also
Pick[data, Unitize[-3 + Length /@ data], 1]
$endgroup$
Also
Pick[data, Unitize[-3 + Length /@ data], 1]
answered 11 hours ago
kglrkglr
186k10202421
186k10202421
add a comment |
add a comment |
1
$begingroup$
Maybe you ask for
DeleteCases[data, _?(Length[#] == 3 &)]
...$endgroup$
– Henrik Schumacher
11 hours ago
$begingroup$
@HenrikSchumacher : sorry, already corrected this.
$endgroup$
– John Taylor
11 hours ago