Skip to content
Data frames & arrays on Clojure
Clojure
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc
examples
resources Add panthera.png Jul 12, 2019
src/panthera Fix subset-cols issue with downcasting Aug 12, 2019
test/panthera Remove regression from subset-cols Aug 12, 2019
.gitignore Bump versions and fix math cov test Jul 24, 2019
LICENSE Init Jun 19, 2019
README.md Refactor Numpy to support submodules Aug 6, 2019
project.clj Fix subset-cols issue with downcasting Aug 12, 2019

README.md

panthera

panthera-logo

Hic sunt leones

Latin phrase reported on many maps indicating Terra incognita, unexplored or harsh land.

What

Dataframes in Clojure. Through pandas. On Python.

Disclaimer

This is very alpha, things will change fast, will break and the API is neither complete, nor settled. Since a few people have started playing with this there's a Clojars project available. Please give feedback if you're using this, every kind of contribution is appreciated (for more info check the Contributing section). At the moment everything is mostly undocumented and untested, I'm currently adding them.

Clojars Project

Get started

Panthera uses the great libpython-clj as a backend to access Python and get pandas and numpy functionality.

To get started you need python, pandas and numpy (the latter comes with the former) on your path. Usually a:

apt-get install libpython3.6-dev
pip3 install numpy pandas xlrd # the latter is for Excel files, if you don't care you can do without

After this you can start playing around with panthera

(require '[panthera.panthera :as pt])

(-> (pt/read-csv "mycsv.csv")
    (pt/subset-cols "Col1" "Col2" "Col3")
    pt/median)

The above chain will read your csv file as a DataFrame, select only the given columns and then return a Series with the median of each column.

panthera.panthera is the home of the main API, and you can find everything there. The advice is to never :use or :refer :all the namespace because there are some functions named as core Clojure functions such as mod which in this case does the same thing as the core one, but in this case it is vectorized and it works only if the first argument is a Python object.

Numpy

All of Numpy is wrapped and accessible through a single interface from panthera.numpy.

(require '[panthera.numpy :refer [npy doc]])

(npy :power {:args [[1 2 3] 3]})
;=> [1 8 27]

(npy :power)
; This arity returns the actual numpy object that can be passed around to other functions as an argument

To access functions inside submodules pass to npy a sequence of keys leading to the wanted function:

(npy [:linalg :svd] {:args [[1 2 3] [4 5 6]]})

You can check the original docstring for every module and function with the doc helper

(doc :power)

(doc [:linalg :eigh])

To see what is available and how everything works check the official docs online.

Contributing

Please let me know about any issues, quirks, ideas or even just to say that you're doing something cool with this! I accept issues, PRs or direct messages (you can find me also on https://clojurians.slack.com and on https://clojurians.zulipchat.com).

Examples

You can find some examples in the examples folder. At the moment that's the best way to start with panthera.

Why "panthera"?

Pandas is derived from "panel data" and somehow is supposed to mean "Python data analysis library" as well. Though it shouldn't have nothing to do with the cute Chinese bears, there are logos showing a bear.

Panthera doesn't pretend to be a clever wordplay because it doesn't need to. First off panthera is latin and it literally means "large cat", second though pandas are surely cute, pantherae are way cooler (and snow leopards also happen to be among the very few predators of pandas, but that's just a case...).

Special thanks

License

Copyright © 2019 Alan Marazzi

This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0.

You can’t perform that action at this time.