Beispiel #1
0
def test_write_dataframe(df_client):
    df1 = utils.random_dataframe()
    df2 = utils.random_dataframe()
    df2.columns = df1.columns
    assert df_client.write(df1, measurement='m1', mytag='foo', tag_columns=['tag'])
    assert df_client.write(df2, measurement='m2', mytag='foo', tag_columns=['tag'])
    assert df_client.write(utils.random_dataframe(), measurement='m3')  # tag-less
Beispiel #2
0
async def test_invalid_data_write_dataframe(client):
    with pytest.raises(ValueError) as e:
        # Non-DatetimeIndex DataFrame
        await client.write(utils.random_dataframe().reset_index(), measurement='foo')
    logger.error(e)

    with pytest.raises(ValueError) as e:
        # DataFrame write without specifying measurement
        await client.write(utils.random_dataframe())
    logger.error(e)
Beispiel #3
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'