Skip to content

Commit

Permalink
Remove regression from subset-cols
Browse files Browse the repository at this point in the history
  • Loading branch information
alanmarazzi committed Aug 12, 2019
1 parent 48c975d commit befafe6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/panthera/pandas/generics.clj
Expand Up @@ -597,7 +597,11 @@
(py/call-attr df-or-srs "head" (or n 5)))

(defn subset-cols
"Select columns by name
"Select columns by name.
Note that `colnames` are treated as literals: there's no
conversion involved, so if you pass a keyword it gets
translated as a string exactly as it is.
**Arguments**
Expand All @@ -622,8 +626,7 @@
;2 6 8
```"
[df & colnames]
(let [cols (u/vec->pylist (map u/memo-key-converter colnames))]
(py/get-item df cols)))
(py/get-item df colnames))

(defn n-largest
"Return the first `:n` values ordered by `:columns` in descending order.
Expand Down
9 changes: 5 additions & 4 deletions test/panthera/generics_test.clj
Expand Up @@ -174,7 +174,6 @@
(g/data-frame i)
cols))
o)
[] nil []
[{:a 1}] [:a] [{:a 1}]
[{:a 1 :b 2 :c 3}] [:a :c] [{:a 1 :c 3}]
(repeat 5 {:a 1 :b 2}) [:b] (repeat 5 {:b 2})
Expand Down Expand Up @@ -272,7 +271,7 @@
(= (vec (g/names (g/data-frame i))) o)
[{:a 1 :b 2}] ["a" "b"]
[{"a name" 1 :c 2}] ["a name" "c"]
[{123 1 1/5 3}] [0.2 123.0]))
[{123 1 1/5 3}] [123.0 0.2]))

(deftest filter-rows
(are [i b o]
Expand All @@ -287,8 +286,10 @@

(g/data-frame [{:a 1 :b 2}
{:a 3 :b 4}])
#(-> (g/subset-cols % :a)
(m/lt 3))
#(-> %
(g/subset-cols :a)
(m/lt 3)
g/values)
[{:a 1 :b 2}]

(g/data-frame [{:a 1 :b 2}
Expand Down

0 comments on commit befafe6

Please sign in to comment.