Beispiel #1
0
def resolve_header(header):
    if header is None:
        return None
    if isinstance(header, dict):
        return get_header(header)
    else:
        return header
Beispiel #2
0
def _dataframe_dict(data, index=None, filler='', header=None):
    if isinstance(data, dict):
        try:
            if depth(data, isiter=True) < 2:
                return data
        except TypeError:
            return data
    if not isinstance(data, dict):
        header = resolve_header(header)
        if header is None:
            header = get_header(data[0])
        data = pack(data, header)
    data = flatten(data)
    data = fill_keys(data, filler)
    return data
Beispiel #3
0
 def test_basic(self):
     header = tuple((n,) for n in names) + tuple(zip(('self',) * len(names), names))
     header2 = dictionary.get_header(basic_dict)
     header2.reverse()
     self.assertEqual(set(header), set(header2))
Beispiel #4
0
 def test_dict(self):
     header = get_header(testdata[0])
     custom_data = fill_keys(flatten(pack(testdata, header)), '')
     result = dataframe_dict(testdata)
     expected = dataframe_dict(custom_data)
     assert_frame_equal(result, expected, check_names=True)