Exemplo n.º 1
0
def test_read_dataframe_groupby(df_client):
    df_dict = df_client.query('SELECT max(*) from /m[1-2]$/ GROUP BY "tag"')
    s = ['\n{}:\n{}'.format(k, v) for k, v in df_dict.items()]
    logger.info('\n'.join(s))
    m1 = pd.concat([df for k, df in df_dict.items() if k.split(',')[0] == 'm1'])
    m2 = pd.concat([df for k, df in df_dict.items() if k.split(',')[0] == 'm2'])
    assert m1.shape == (5, 6)
    assert m2.shape == (5, 6)
Exemplo n.º 2
0
async def test_dataframe_chunked_query(client):
    client.output = 'dataframe'

    df1 = utils.random_dataframe()
    await client.write(df1, measurement='m3')

    cursor = await client.query('SELECT * FROM m3', chunked=True, chunk_size=10)
    dfs = []
    async for subdf in cursor:
        assert isinstance(subdf, pd.DataFrame)
        assert len(subdf) == 10
        dfs.append(subdf)
    df = pd.concat(dfs)
    assert df.shape == (50, 7)

    client.output = 'json'