/panthera

Data-frames & arrays on Clojure

Primary LanguageClojureEclipse Public License 2.0EPL-2.0

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 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.

N.B.: check libpython-clj repo on how to install and start a Clojure/Python session.

The actual code

After this you can start playing around with panthera

(require '[[panthera.panthera :as pt]
           [libpython-clj.python :refer [initialize!]])
           
(initialize!)

(-> (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 accessible through libpython-clj interop, check the repo for more info.

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 © 2020 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.