Exemple #1
0
def test_format_grid(unittest):
    output = utils.format_grid(
        pd.DataFrame([dict(a=1, b='foo', c=3.5, d=pd.Timestamp('20190101'))]))
    unittest.assertEqual(
        output, {
            'results': [{
                'a': 1,
                'c': 3.5,
                'b': 'foo',
                'd': '2019-01-01'
            }],
            'columns': [{
                'dtype': 'int64',
                'name': 'a'
            }, {
                'dtype': 'string',
                'name': 'b'
            }, {
                'dtype': 'float64',
                'name': 'c'
            }, {
                'dtype': 'datetime64[ns]',
                'name': 'd'
            }]
        }, 'should format dataframe correctly')
Exemple #2
0
def test_format_grid(unittest):
    output = utils.format_grid(
        pd.DataFrame([dict(a=1, b="foo", c=3.5, d=pd.Timestamp("20190101"))]))
    unittest.assertEqual(
        output,
        {
            "results": [{
                "a": 1,
                "c": 3.5,
                "b": "foo",
                "d": "2019-01-01"
            }],
            "columns": [
                {
                    "dtype": "int64",
                    "name": "a"
                },
                {
                    "dtype": "string",
                    "name": "b"
                },
                {
                    "dtype": "float64",
                    "name": "c"
                },
                {
                    "dtype": "datetime64[ns]",
                    "name": "d"
                },
            ],
        },
        "should format dataframe correctly",
    )