def test_display_type_color_a(self) -> None: f = sf.Frame.from_dict(dict( a=(1, 2), b=(1.2, 3.4), c=(False, True), e=(1j, 3j), f=(np.datetime64('2014'), np.datetime64('2015')), ), index=tuple('xy')) print(f) print(f.loc['x']) sf.DisplayActive.set(sf.DisplayConfigs.COLOR) print(f.display(sf.DisplayConfigs.COLOR)) print(f.loc['x'].display(sf.DisplayConfigs.COLOR)) f = sf.Frame.from_dict( dict(a=(1, 2, 3, 4), b=(True, False, True, False), c=list('qrst'))) f = f.set_index_hierarchy(['a', 'b']) f = f.relabel_add_level(columns='I') f = f.relabel_add_level(columns='J') print(f) # columns = sf.IndexHierarchy.from_product((96361, 96345), (0, 1)) # index = sf.IndexHierarchy.from_product((32155, 32175), (0, 4)) # columns = range(4) # index = range(4) # f = sf.Frame.from_records( # ([y for y in range(x, x + 4)] for x in range(4)), # index=index, columns=columns) from itertools import product index: tp.Iterable[tp.Hashable] = (0x2210, 0x2330) columns: tp.Iterable[tp.Hashable] = (0x1, 0xe) f = sf.Frame.from_element_loc_items( ( (x, chr(sum(x))) for x in product(index, columns) ), # type: ignore # Should probably open a typeshed issue for this. index=index, columns=columns, dtype=str) print(f) columns = list('abcdefgh') index = range(1, 9) f = sf.Frame(np.empty((8, 8), dtype='U1'), columns=columns, index=index) print(f) columns = tuple('efgh') index = range(3, 0, -1) f = sf.Frame.from_element_loc_items( ( ((2, 'f'), chr(0x265F)), # pawn ((2, 'g'), chr(0x265F)), ((2, 'h'), chr(0x265F)), ((1, 'e'), chr(0x265A)), # king ((1, 'h'), chr(0x265C)), # rook ), index=index, columns=columns, dtype=str) #part of Sicilian Defense Najdorf Variation columns = tuple('hgfe') index = range(6, 9) f = Frame.from_element_loc_items( ( ((7, 'h'), chr(0x265F)), # pawn ((6, 'g'), chr(0x265F)), ((7, 'f'), chr(0x265F)), ((7, 'e'), chr(0x265F)), ((8, 'e'), chr(0x265A)), # king ((7, 'g'), chr(0x265D)), # biship ((6, 'f'), chr(0x265E)), # horse ((8, 'h'), chr(0x265C)), # rook ), index=index, columns=columns, dtype=str) s1 = Series.from_items((('f', chr(0x265C)), ('g', chr(0x265A)))) f.assign.loc[8, :](s1, fill_value='')
def test_display_type_color_a(self): f = Frame(dict(a=(1, 2), b=(1.2, 3.4), c=(False, True), d=(object(), []), e=(1j, 3j), f=(np.datetime64('2014'), np.datetime64('2015')), g=(np.datetime64('2014') - np.datetime64('2015'), np.datetime64('2014') - np.datetime64('2015'))), index=tuple('xy')) print(f) print(f.loc['x']) print(f.display(DisplayConfigs.COLOR)) print(f.loc['x'].display(DisplayConfigs.COLOR)) f = sf.Frame( dict(a=(1, 2, 3, 4), b=(True, False, True, False), c=list('qrst'))) f = f.set_index_hierarchy(['a', 'b']) f = f.reindex_add_level(columns='I') f = f.reindex_add_level(columns='J') print(f) # columns = sf.IndexHierarchy.from_product((96361, 96345), (0, 1)) # index = sf.IndexHierarchy.from_product((32155, 32175), (0, 4)) # columns = range(4) # index = range(4) # f = sf.Frame.from_records( # ([y for y in range(x, x + 4)] for x in range(4)), # index=index, columns=columns) from itertools import product index = (0x2210, 0x2330) columns = (0x1, 0xe) f = Frame.from_element_loc_items( ((x, chr(sum(x))) for x in product(index, columns)), index=index, columns=columns, dtype=str) print(f) columns = list('abcdefgh') index = range(1, 9) f = sf.Frame(np.empty((8, 8), dtype='U1'), columns=columns, index=index) print(f) # f.display(sf.DisplayActive.get(display_format='html_datatables')) # f.to_html_datatables() columns = tuple('efgh') index = range(3, 0, -1) f = Frame.from_element_loc_items( ( ((2, 'f'), chr(0x265F)), # pawn ((2, 'g'), chr(0x265F)), ((2, 'h'), chr(0x265F)), ((1, 'e'), chr(0x265A)), # king ((1, 'h'), chr(0x265C)), # rook ), index=index, columns=columns, dtype=str) #part of Sicilian Defense Najdorf Variation columns = tuple('hgfe') index = range(6, 9) f = Frame.from_element_loc_items( ( ((7, 'h'), chr(0x265F)), # pawn ((6, 'g'), chr(0x265F)), ((7, 'f'), chr(0x265F)), ((7, 'e'), chr(0x265F)), ((8, 'e'), chr(0x265A)), # king ((7, 'g'), chr(0x265D)), # biship ((6, 'f'), chr(0x265E)), # horse ((8, 'h'), chr(0x265C)), # rook ), index=index, columns=columns, dtype=str) # s = Series(('', chr(0x265C), '', chr(0x265A)), index=tuple('efgh')) # s = Series.from_items((('f', chr(0x265C)), ('h', chr(0x265A)))).reindex(tuple('efgh'), fill_value='') s = Series.from_items((('f', chr(0x265C)), ('g', chr(0x265A)))) f.assign.loc[8, :](s, fill_value='')