Skip to content

Commit

Permalink
Add draft of sort-values fn
Browse files Browse the repository at this point in the history
  • Loading branch information
ezmiller committed Mar 21, 2020
1 parent d35232e commit e121256
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/panthera/pandas/generics.clj
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,59 @@
[df-or-srs & [attrs]]
(u/simple-kw-call df-or-srs "nunique" attrs))

(defn sort-values
"Sort values in a series or along any axis in a data-frame, series or index.
**Arguments**
- `df-or-srs` -> data-frame, series
**Attrs**
- For data-frame: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.sort_values.html#pandas.DataFrame.sort_values
- For series: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.sort_values.html
- For index: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Index.sort_values.html
**Commonly Used Attrs**
- `by`* -> keyword, str, or vector of keywords or strs, the name or list of names to sort by.
- `:ascending` -> bool, default: true
* Only for data-frames.
**Examples**
```
(sort-values (series [2 20 4]))
; 0 2
; 2 4
; 1 20
; dtype: int64
(sort-values (series [2 20 4]) {:ascending false})
; 1 20
; 2 4
; 0 2
; dtype: int64
(data-frame [{:a 2 :b 1} {:a 20 :b 2} {:a 4 :b 3}])
; a b
; 0 2 1
; 1 20 2
; 2 4 3
(sort-values df {:by :a})
; a b
; 0 2 1
; 2 4 3
; 1 20 2
```"
[df-or-srs & [attrs]]
(u/simple-kw-call df-or-srs "sort_values" attrs))

(sort-values (series [2 3 1]))

(defn- preds
"Dispatcher to avoid repetition"
[k]
Expand All @@ -753,6 +806,8 @@
((ks k) seq-or-srs)
(recur (series seq-or-srs))))))



(def unique?
"Return wether the values in the given collection are unique.
Expand Down

0 comments on commit e121256

Please sign in to comment.