Skip to content

littletable 2.0.7

Compare
Choose a tag to compare
@ptmcg ptmcg released this 07 May 22:19
· 139 commits to master since this release
  • Added support for sliced indexing into Table indexes, as a simple form of range selection and filtering.

      # old style:
      # employees.where(salary=Table.ge(50000))
      employees.create_index("salary")
      employees.by.salary[50000:]
    

    Unlike Python list slices, Table index slices can use non-integer data types (as long as they support >= and < comparison operations):

      jan_01 = datetime.date(2000, 1, 1)
      apr_01 = datetime.date(2000, 4, 1)
    
      # old style:
      # first_qtr_sales = sales.where(date=Table.in_range(jan_01, apr_01))
      sales.create_index("date")
      first_qtr_sales = sales.by.date[jan_01: apr_01]
    

    Slices with a step field (as in [start : stop : step]) are not supported.

    See full example code in examples/sliced_indexing.py.

  • Added new transform methods for importing timestamps as part of CSV's.

    • Table.parse_datetime(pattern, empty, on_error)
    • Table.parse_date(pattern, empty, on_error)
    • Table.parse_timedelta(pattern, reference_time, empty, on_error)

    Each takes a pattern as would be used for datetime.strptime()``, plus optional values for empty inputs (default='') or error inputs (default=None). parse_timedelta` also takes a reference_time argument to compute the resulting timedelta - default is 00:00:00.

    See full example code in examples/time_conversions.py.

  • as_html() now accepts an optional dict argument table_properties, to add HTML <table>-level attributes to generated HTML:

      tbl = lt.Table().csv_import("""\
          a,b,c
          1,2,3
          4,5,6
          """)
      html = tbl.as_html(fields="a b c", table_properties={"border": 1, "cellpadding": 5}
    
  • Workaround issue when running Table.present() in a terminal environment that does not support isatty():

    AttributeError: 'OutputCtxManager' object has no attribute 'isatty'