#0 #1 #2 #3 #4 #5 #6 #7 #8 #9 #10 #11
-- -- -- -- -- -- -- -- -- --- --- ---
1 11 21 31 41 51 61 71 81 91 101 111
2 12 22 32 42 52 62 72 82 92 102 112
3 13 23 33 43 53 63 73 83 93 103 113
4 14 24 34 44 54 64 74 84 94 104 114
5 15 25 35 45 55 65 75 85 95 105 115
6 16 26 36 46 56 66 76 86 96 106 116
7 17 27 37 47 57 67 77 87 97 107 117
8 18 28 38 48 58 68 78 88 98 108 118
9 19 29 39 49 59 69 79 89 99 109 119
10 20 30 40 50 60 70 80 90 100 110 120
I can access consecutive columns at the position 1-4 using m[:, 1:5]
in DolphinDB, but it cannot work when retrieving separate columns. For example, I’d like to obtain the columns at the position 1, 9, and 10, but m[:,[1,9,10]]
returns an error message:
colIndex must be a scalar value or a range
How can I access separate columns in a matrix in DolphinDB?
You can access the matrix with
m[1,9,10]
to retrieve the columns:output
To obtain separate rows (e.g. rows 1, 3 and 5):
output
To obtain specific cells:
DolphinDB version 2.00.8 also offers a new function loc which has the same function as pandas
loc
. For example: