GitXplorerGitXplorer
W

lesser

public
6 stars
2 forks
0 issues

Commits

List of commits on branch master.
Unverified
13373ddb6d1ad9b4d7664408179aeed5d153b4fe

bump

WWuTheFWasThat committed a year ago
Unverified
afdcd167b15b5583e768e8bd5f1a985f52fb50db

allow slices and indexing

WWuTheFWasThat committed a year ago
Unverified
e19766d3578c0bddb78eb75426f59fd656b32cee

bump

WWuTheFWasThat committed 3 years ago
Unverified
5ae47963749637eb91166d9c36ab67f91130dc84

add values_at function

WWuTheFWasThat committed 3 years ago
Verified
aa28743a5eb73b29a834b6b2af0d462525b70caf

Update README.md

WWuTheFWasThat committed 3 years ago
Unverified
aa253e3292917350179e50fcb7e7034b319b0ffd

expose key missing

WWuTheFWasThat committed 3 years ago

README

The README file for this repository.

Lesser 🐼

This is a tiny data manipulation library, very loosely based on pandas. The core object is just a dict of lists (where each list has the same length). We tack on a bunch of methods and call it a frame.

It is not fast, but it is very simple.

Install

pip install lesser

Usage

It's most easily understood by example!

import lesser as lpd
import numpy as np

frame = lpd.from_dicts([
  dict(name="Alice",   day=0, sleep_mins=500, reaction_time=60),
  dict(name="Alice",   day=1, sleep_mins=420, reaction_time=81),
  dict(name="Bob",     day=0, sleep_mins=540, reaction_time=62),
  dict(name="Bob",     day=1, sleep_mins=520, reaction_time=71),
  dict(name="Charles", day=0, sleep_mins=340, reaction_time=88),
  dict(name="Charles", day=1, sleep_mins=410, reaction_time=94),
])
print(frame['name'])

reactions_by_sleep = (
    frame.compute_key("sleep_hours", lambda x: x['sleep_mins'] // 60)
    # group_by makes a frame with key=[some computed key] and values=[a frame with all original items with that same computed key]
    .group_by("sleep_hours")
    .compute_key("sleep_hours", lambda x: x["key"])
    .compute_key(
        "average_reaction_time", lambda x: np.mean(x["values"]["reaction_time"])
    )
    .sort_by(lambda x: x["sleep_hours"])
)

print(reactions_by_sleep)
import matplotlib.pyplot as plt
# A misleading chart
plt.plot(
    reactions_by_sleep["sleep_hours"],
    reactions_by_sleep["average_reaction_time"],
)
plt.show()

There's no other documentation, so you'll have to read the source (which is quite short).

Development

Run tests

pytest