def test_serialize_pandas_no_preserve_index(): df = pd.DataFrame({'a': [1, 2, 3]}, index=[1, 2, 3]) expected = pd.DataFrame({'a': [1, 2, 3]}) buf = pa.serialize_pandas(df, preserve_index=False) result = pa.deserialize_pandas(buf) assert_frame_equal(result, expected) buf = pa.serialize_pandas(df, preserve_index=True) result = pa.deserialize_pandas(buf) assert_frame_equal(result, df)
async def post_handler(request): # print(request.body) # bb = io.BytesIO(request.body) bb = pa.py_buffer(request.body) # br = pa.BufferReader(request.body) df = pa.deserialize_pandas(bb) print(df.shape) return raw(b'HI')
def test_pandas_serialize_round_trip_nthreads(): index = pd.Index([1, 2, 3], name='my_index') columns = ['foo', 'bar'] df = pd.DataFrame( {'foo': [1.5, 1.6, 1.7], 'bar': list('abc')}, index=index, columns=columns ) buf = pa.serialize_pandas(df) result = pa.deserialize_pandas(buf, nthreads=2) assert_frame_equal(result, df)
def test_pandas_serialize_round_trip_multi_index(): index1 = pd.Index([1, 2, 3], name='level_1') index2 = pd.Index(list('def'), name=None) index = pd.MultiIndex.from_arrays([index1, index2]) columns = ['foo', 'bar'] df = pd.DataFrame( {'foo': [1.5, 1.6, 1.7], 'bar': list('abc')}, index=index, columns=columns, ) buf = pa.serialize_pandas(df) result = pa.deserialize_pandas(buf) assert_frame_equal(result, df)
def get(cls, list_quandle_series, start_date, end_date): r = requests.get( 'http://localhost:{}/v1.0/data/multiple'.format(_port), params={ 'list_series': list_quandle_series, 'start_date': start_date, 'end_date': end_date }) if r.status_code == 200: return pyarrow.deserialize_pandas(r.content) else: raise Exception("unable to acquire data: HTTP code: ".format( r.status_code))
def test_pandas_serialize_round_trip_not_string_columns(): df = pd.DataFrame(list(zip([1.5, 1.6, 1.7], 'abc'))) buf = pa.serialize_pandas(df) result = pa.deserialize_pandas(buf) assert_frame_equal(result, df)
def time_deserialize_pandas(self): pa.deserialize_pandas(self.serialized)
def _check_serialize_pandas_round_trip(df, nthreads=1): buf = pa.serialize_pandas(df, nthreads=nthreads) result = pa.deserialize_pandas(buf, nthreads=nthreads) assert_frame_equal(result, df)
def _check_serialize_pandas_round_trip(df, use_threads=False): buf = pa.serialize_pandas(df, nthreads=2 if use_threads else 1) result = pa.deserialize_pandas(buf, use_threads=use_threads) assert_frame_equal(result, df)
def _deserialize_pandas_series(data): deserialized = deserialize_pandas(data) return deserialized[deserialized.columns[0]]
def _deserialize_pandas_dataframe(data): return deserialize_pandas(data)
def deserialize(b): try: obj = pickle.loads(b) except pickle.UnpicklingError: obj = pa.deserialize_pandas(b) return obj