New answers tagged

2

First, let's do it with datasets having unnamed columns, because they are simpler. We use Intersection to find common elements in the first column. We use a simple replacement rule that replaces a list, which represents a row in the dataset, with Nothing. {nest1, nest2} = {{{"A", 1}, {"B", 2}, {"C", 3}, {"D", 4}}, {{"A", 111}, {"C", 333}, {"E", 555}}...


5

GeneralUtilities`PrintDefinitions@SavitzkyGolayMatrix


3

We can use Complement to find the elements in set1 whose ID values are not contained within set2: Complement[set1, set2, SameTest -> (#["ID"] === #2["ID"] &)] Update for the revised question Complement provides a nice notational convenience, but for large (15,000) sets it runs orders of magnitude slower than the solution proposed in the question. ...


5

This should work: Select[ll, AllTrue[#, NumericQ] &] {{1, 2, 3}, {[Pi], 4, 5}}


1

Using replacement rules: SomeData /. x : {a_, b_, c_} :> If[b - c < 0.2, Most@x, {a, 999999}] (* {{0., 999999}, {0.5, 999999}, {1., 1.538}, {1.5, 999999}, {2., 0.6}, {2.5, 999999}, {3., 0.149}, {3.5, 0.408}, {4., 1.141}, {4.5, 1.696}, {5., 1.833}, {5.5, 999999}, {6., 2.1}, {6.5, 1.773}, {7., 999999}, {7.5, 0.889}, {8., 999999}, {8.5, 0....


3

ClearAll[clip]; clip[δ_, repl_: 9999][{a_, b_, c_}] := {a, Clip[b, {-∞, c + δ - 2 $MachineEpsilon}, {-∞, repl}]}; Map[clip[.2]] @ SomeData {{0., 9999}, {0.5, 9999}, {1., 1.538}, {1.5, 9999}, {2., 0.6}, {2.5, 9999}, {3., 0.149}, {3.5, 0.408}, {4., 1.141}, {4.5, 1.696}, {5., 1.833}, {5.5, 9999}, {6., 2.1}, {6.5, 1.773}, {7., 9999}, {...


2

Would something like this do what you want: Block[{outlierPositions = Flatten[Position[SomeData, #] & /@ Select[SomeData, ! (#[[2]] - #[[3]] < 0.2) &], 1], replacements}, replacements = Append[#, 2] & /@ outlierPositions; ReplacePart[SomeData, replacements -> 999999][[;; , {1, 2}]] ] (*{{0., 999999}, {0.5, 999999}, {1., 1....


7

Is this ok? Select[GatherBy[l, #[[{-2, -1}]] &], Length[#] > 1 &] {{{1, 2, 3, 6, 6}, {1, 2, 4, 6, 6}}, {{1, 2, 5, 8, 8}, {1, 2, 6, 8, 8}}}


3

Try Binomial: prb[tot_, sub_] := 1 - Binomial[tot - sub, 5]/Binomial[tot, 5]


7

You can use GatherBy, SplitBy or GroupBy as follows: min1 = First /@ GatherBy[Sort@list, Most] {{0, 2, 1}, {0, 3, 0}, {1, 2, 0}, {2, 2, 0}} max1 = Last /@ GatherBy[Sort@list, Most] {{0, 2, 3}, {0, 3, 0}, {1, 2, 0}, {2, 2, 1}} Alternatively, min2 = First /@ SplitBy[Sort@list, Most]; max2 = Last /@ SplitBy[Sort@list, Most]; min3 = First@*MinimalBy[...


Top 50 recent answers are included