Littletable

Latest version: v2.2.5

Safety actively analyzes 630450 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 3 of 7

2.0.4

-------------
- Added grouping support in Table.present(), Table.as_html() and
Table.as_markdown(). Pass `groupby` parameter to indicate grouping
field.

tbl.present(groupby="ColumnA")

will display the table with repeated consecutive values for ColumnA
suppressed.

Multiple fields can be specified for grouping using a space-delimited
string. If multiple fields are given, they will be grouped hierarchically;
that is, the second field will group only if already grouping on the first
field, the third field will group only if already grouping on the second
field, etc. (For best grouping output, sort the records first.)

tbl = lt.Table("Academy Awards").csv_import("""\
year,award,movie,recipient
1960,Best Picture,Ben-Hur,
1960,Best Actor,Ben-Hur,Charlton Heston
1960,Best Actress,The Heiress,Simone Signoret
1960,Best Director,Ben-Hur,William Wyler
...
""")

tbl.present(groupby="year")

Academy Awards
Year Award Movie Recipient
────────────────────────────────────────────────────────────────────────────
1960 Best Picture Ben-Hur
Best Actor Ben-Hur Charlton Heston
Best Actress The Heiress Simone Signoret
Best Director Ben-Hur William Wyler
1961 Best Picture The Apartment
Best Actor Elmer Gantry Burt Lancaster
Best Actress Butterfield 8 Elizabeth Taylor
Best Director The Apartment Billy Wilder
1962 Best Picture West Side Story
Best Actor Judgment at Nuremberg Maximilian Schell
Best Actress Two Women Sophia Loren
Best Director West Side Story Willian Wise/Jerome Robbins

- Modified the table created by stats() to include a 'missing' column,
and reordered the columns so that when presented, the most likely interesting
stat (mean) is listed first.

- Added attributes to Table to record import source and type for csv_import,
tsv_import, and json_import. For imports from files or web urls, the
filename or url will be added as the table's default title.

- Added support and test cases for storing objects using the HasTraits
classes from the traits and traitlets packages. (Working with HasTraits
objects in a littletable.Table requires that they add littletable.HasTraitsMixin
to their inheritance classes).

- Added test cases for storing objects created using the attrs package.

2.0.3

-------------
- Fixed bug introduced when adding support for auto-centering, if data
is not numeric or str but has no __len__ method.

- Cleaned up how_to_use_littletable.md docs to reflect recent changes and
new features.

2.0.2

-------------
- Added unit tests to support using pydantic.BaseModel as Table contents.

- All xxx_import and _export methods will now accept a pathlib.Path to
reference the source or destination file.

- Fixed internally-reported version number (2.0.1 erroneously reported
its version as 2.0.0).

2.0.1

-------------
- Fixed setup.py and setup.cfg to generate Py3-only wheel.

2.0.0

-------------
- Discontinued support for Python 2.x, and Python 3 versions earlier than
Python 3.6.

- Added new comparators:

is_none - attribute value is None
is_not_none - attribute value is not None
is_null - attribute value is None, "", or not defined
is_not_null - attribute value is defined, and is not None or ""
startswith - attribute value starts with a given string
endswith - attribute value ends with a given string
re_match - attribute value matches a regular expression

Examples:
get customers whose address includes an apartment number
has_apt = customers.where(address_apt_no=Table.is_not_null())

get employees whose first name starts with "X"
x_names = employees.where(name=Table.startswith("X"))

get log records that match a regex (any word starts with
"warn" in the log description)
(re_match will accept re flags argument)
warnings = log.where(description = Table.re_match(r".*\bwarn", flags=re.I)

- Added type annotations for public API methods.

- New examples:
- explore_unicode.py - code for exploring subset of the Unicode database,
showing several interesting symbol groups
- dune_casts.py - joining 3 tables to create a table showing the casts of
the 3 studio productions of Dune

- Nicer present() output - auto-center columns where all values
are single characters (centers "X", "Y", "N", etc. values).

1.5.0

-------------
- Table.insert_many() now accepts a sequence of Python dicts for objects
to insert into a table (and Table.insert() will accept a single dict).
They get stored as SimpleNamespace objects to support all attribute
accesses.

- Added Table.as_markdown() to generate a string representing the
table using Markdown syntax.

- Added Table.splitby() - takes a predicate function (takes a table
record and returns True or False) and returns two tables: a table with
all the rows that returned False and a table with all the rows that
returned True. Will also accept a string indicating a particular field
name, and uses `bool(getattr(rec, field_name))` for the predicate
function.

is_odd = lambda x: bool(x % 2)
evens, odds = tbl.splitby(lambda rec: is_odd(rec.value))
nulls, not_nulls = tbl.splitby("optional_data_field")

Page 3 of 7

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.