Beispiel #1
0
def test_parquet_file():
    ohlc = read_pd("ohlc.csv", index_col="time", parse_dates=True)

    with tempfile.NamedTemporaryFile() as temp:
        ohlc.to_parquet(temp.name, engine='auto', compression=None)
        r = pd.read_parquet(temp.name, engine='auto')

        pt.assert_frame_equal(ohlc, r)
Beispiel #2
0
def test_parquet_field():
    class Maffay(Document):
        frame = ParquetFrameField(engine="pyarrow", compression="gzip")

    maffay = Maffay()
    ohlc = read_pd("ohlc.csv", index_col="time", parse_dates=True)
    maffay.frame = ohlc

    pt.assert_frame_equal(maffay.frame, ohlc)
Beispiel #3
0
def test_parquet_bytes_io():
    # https://github.com/pandas-dev/pandas/issues/34467
    # This does not work with pandas 1.0.4!
    ohlc = read_pd("ohlc.csv", index_col="time", parse_dates=True)

    buffer = BytesIO()
    ohlc.to_parquet(buffer, engine='auto', compression=None)

    # don't write buffer to disc
    r = pd.read_parquet(buffer, engine='auto')
    pt.assert_frame_equal(ohlc, r)
Beispiel #4
0
def test_frame():
    Singer.objects.delete()
    s1 = Singer(name="Falco").save()
    s2 = Singer(name="Peter Maffay").save()

    s1.price = pd.Series(index=[1, 2, 3], data=[7.0, 9.0, 8.0])
    s2.price = pd.Series(index=[1, 3], data=[8.0, 10.0])
    s1.save()
    s2.save()

    f = Singer.frame(series="price")
    #print(f)
    #f.to_csv(resource("frame.csv"))
    pt.assert_frame_equal(f, read_pd("frame.csv", index_col=0))
Beispiel #5
0
def test_frame():
    Singer.objects.delete()
    s1 = Singer(name="Falco").save()
    s2 = Singer(name="Peter Maffay").save()
    s3 = Singer(name="Karel Gott").save()

    s1.price = pd.Series(index=[1, 2, 3], data=[7.0, 9.0, 8.0])
    s2.price = pd.Series(index=[1, 3], data=[8.0, 10.0])
    s1.save()
    s2.save()

    f = Singer.frame(series="price")
    pt.assert_frame_equal(f, read_pd("frame.csv", index_col=0))

    with pytest.raises(AttributeError):
        Singer.frame(series="wurst")
Beispiel #6
0
def prices():
    return read_pd("price.csv", index_col=0, parse_dates=True)
Beispiel #7
0
def ts():
    return read_pd("ts.csv", squeeze=True, index_col=0, parse_dates=True)