# Data Manipulation

I currently have $n$ datapoints along $k$ dimensions ($n$ observations and $k$ variables). I need to drop a lot of these observations by some criteria. To be more specific, I have to perform a few operations of the following type:

1. Drop if for the $k^{th}$ variable, the value of the observations is less than 50.
2. Drop if for the $(k-1^{th})$ variable, the value of the observations is less than 60.

etc. etc.

Does it matter in which order I perform these operations? Will I end up with exactly the same dataset?

In short, yes you will. Each of your operations forms a boolean operation, e.g. in your first case $x_k \ge 60$. The remaining data are those that return true for all of these operations.

By the associative property of logical conjunction, it doesn't matter what order you apply them in.

Some python to demonstrate:

def firstFilter(t):
return t[0] > 20
def secondFilter(t):
return t[1] > 40
aSetToFilter = zip(range(30), [i + 20 for i in range(30)])
print [i for i in [i for i in aSetToFilter if secondFilter(i)] if firstFilter(i)], [i for i in [i for i in aSetToFilter if firstFilter(i)] if secondFilter(i)]


Will output this same list twice:

[(21, 41), (22, 42), (23, 43), (24, 44), (25, 45), (26, 46), (27, 47), (28, 48), (29, 49)]