Tag Info

New answers tagged

1

gogoolplex's suggestion to use SemanticImport is probably the easiest solution to your particular problem, but here is a way to assemble a dataset yourself. table = {{"naam A", "naam B", "naam C", "naam D"}, {1, 2, 1.2, "a"}, {2, 3, 2.3, "b"}, {3, 4, 2.3, "c"}, {4, 5, 4.5, "d"}, {5, 6, 5.6, "e"}, {6, 7, 6.7, "f"}, {7, 8, 7.8, "g"}, {8, 9, 8.9, "h"}, {9, ...


2

Much, if not all, of the desired functionality may be in the new, MMA-10 Association type. In earlier versions, I got a lot of mileage out of the following techniques: Lists of rules can also act like structs: ClearAll[x, y, myStruct] myStruct = {x -> 42, y -> 47} instead of myStruct.x, which you would do in a C-like syntax, you do x/.myStruct ...


0

Here is one that seems fast (and only checks the first row, as the OP suggested in the question): c[[ All, Flatten@Select[ Partition[Range@Length@First@c, 2] , c[[1, #]] != {0, Null} &] ]]


2

Transpose[c] //. {before___, {0..}, {Null..}, after___} :> {before, after} // Transpose { {31, d31}, {32, d32}, { 0, Null}, {34, d34} } Update: In case of column headers as in the comment below, the patterns in the rule need to modified slightly: Transpose[c] //. {before___, {_, 0..}, {_, Null..}, after___} :> {before, after} // ...


3

c /. (0 | Null) -> Sequence[] // MatrixForm DeleteCases[MapIndexed[pos, c, {2}, Heads -> False], pos[0 | Null, _], 2] // MatrixForm


4

Here's another way typical for Mathematica: c //. {a___, _, Null, b___} :> {a, b}


15

I'm the developer of Dataset. Yes, this is a gross documentation oversight. We planned this functionality but had to push it back to a point release. Somehow no-one caught this piece of legacy documentation. I'm filed a bug on the documentation problem right now, it's easy to fix. As for when L-value assignment will be available, I'm hoping 10.0.1 or ...


5

Though I don't know what is the efficiency impact of it, a workaround could be converting the Dataset to Association by Normal, making the update on the Association, then converting it back to Dataset. ds = Dataset[{<|"a" -> 1, "b" -> "x"|>, <|"a" -> 2, "b" -> "y"|>, <|"a" -> 6, "b" -> "z"|>}] ds = Module[{temp = ...


14

Here are a few ways, each of which operates upon the individual component associations. We can explicitly construct a new association that includes all of the old columns and adds a new one: ds[All, <| "col1"->"col1", "col2"->"col2", "col3"->(#col1 + #col2&) |>] (* col1 col2 col3 1 2 3 3 4 7 5 6 11 *) This ...



Top 50 recent answers are included