Exemple #1
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
Exemple #2
0
 def test_basic(self):
     keys = [(n, None) for n in names]
     keys.extend(('self', n) for n in names)
     flat = dictionary.flatten(basic_dict)
     filled = dictionary.fill_keys(flat)
     self.assertEqual(set(keys), set(filled))
Exemple #3
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)