Drop Rows from List: Problem Solved

  • Thread starter raymound
  • Start date
In summary, the speaker has a list and wants to drop specific rows based on a list of id's. They have tried using the Drop[MC, {id}] command in a loop, but the id's keep changing as they drop rows. They are looking for a solution where the id's will not change as they drop rows.
  • #1
raymound
13
0
hi
I have a list which I want to drop some of it's rows
and I have the id of the rows I want to drop in a list and there's no algorythem in the list

how can I do that?
I know the Command Drop[MC, {id}] whould drop the row number id but if I put this in a loop and try to drop them one by one the id's whould change since I'm dropping some rows and I tried to figure a way out of it but the just didn't work, any help?

the first one in my list and the second one the id of the rows to be dropped

PHP:
{{0.00414938, 6.}, {0.00438052, 5.9}, {0.00460842, 5.8}, {0.00482298, 
  5.7}, {0.0050097, 5.6}, {0.00515407, 5.5}, {0.00517174, 
  5.4}, {0.00504864, 5.3}, {0.00469823, 5.2}, {0.00402235, 
  5.1}, {0.0029449, 5.}, {0.00165498, 4.9}, {-0.00110326, 
  4.8}, {-0.00556929, 4.7}, {-0.0113029, 4.6}, {-0.0183193, 
  4.5}, {-0.0258924, 4.4}, {-0.0363815, 4.3}, {-0.0540341, 
  4.2}, {-0.0762913, 4.1}, {-0.0978172, 4.}, {-0.120518, 
  3.9}, {-0.15479, 3.8}, {-0.188365, 3.7}, {-0.221846, 
  3.6}, {-0.250625, 3.5}, {-0.283568, 3.4}, {-0.276114, 
  3.3}, {-0.227546, 3.2}, {-0.129161, 3.1}, {0.0897719, 
  3.}, {0.511911, 2.9}, {1.19876, 2.8}, {2.32358, 2.7}, {4.16475, 
  2.6}, {7.02193, 2.5}, {11.4346, 2.4}, {18.2226, 2.3}, {28.5117, 
  2.2}, {44.0589, 2.1}, {67.3399, 2.}, {"", ""}}

PHP:
{2, 3, 4, 5, 7, 8, 9, 10, 12, 13, 14, 15, 17, 18, 19, 20, 22, 24, 26,
28, 30, 32, 34, 36, 38, 40}
 
Physics news on Phys.org
  • #2
raymound said:
if I put this in a loop and try to drop them one by one the id's would change since I'm dropping some rows

What if your loop drops them one by one starting with the end of your list instead of the beginning?

First drop row 40 and then drop row 38 and then drop row 36 ... and then drop row 2.

The number of rows remaining in your list would decrease with each iteration, but by doing this in reverse order of the id's that you still need to delete would not change.
 

What is the problem with dropping rows from a list?

The problem with dropping rows from a list is that it can potentially alter the data in the list, leading to inaccurate results or incorrect analysis. Additionally, it can be time-consuming and tedious to manually drop rows from a large list.

How can dropping rows affect the integrity of the data?

Dropping rows from a list can affect the integrity of the data by altering the overall distribution and patterns within the data. This can lead to biased or incorrect conclusions being drawn from the data.

What is the solution to the problem of dropping rows from a list?

The solution to this problem is to use data cleaning techniques such as imputation or outlier detection to address missing or erroneous data. Alternatively, using statistical methods such as regression analysis can help to mitigate the effects of dropped rows.

Are there any downsides to dropping rows from a list?

Yes, there are potential downsides to dropping rows from a list. It can lead to a loss of data, which can impact the overall sample size and accuracy of the analysis. Additionally, dropping rows can also introduce bias into the data if not done carefully.

How can I avoid the need to drop rows from a list?

To avoid the need to drop rows from a list, it is important to carefully collect and clean the data before analysis. This includes addressing missing or erroneous data and using appropriate statistical techniques to handle outliers. It is also important to carefully consider the potential implications of dropping rows and to use it as a last resort.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Introductory Physics Homework Help
Replies
2
Views
1K
  • Science and Math Textbooks
Replies
5
Views
2K
  • Poll
  • Science and Math Textbooks
Replies
5
Views
12K
  • Precalculus Mathematics Homework Help
Replies
2
Views
2K
  • Programming and Computer Science
2
Replies
41
Views
4K
  • Poll
  • Science and Math Textbooks
Replies
4
Views
9K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
1K
  • Poll
  • Science and Math Textbooks
Replies
4
Views
3K
Back
Top