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)
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)
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)
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))
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")
def prices(): return read_pd("price.csv", index_col=0, parse_dates=True)
def ts(): return read_pd("ts.csv", squeeze=True, index_col=0, parse_dates=True)