Ejemplo n.º 1
0
    def to_file(self, file_name, path='.'):
        path_name = os.path.join(path, file_name)

        metadata = self.get_properties()

        packers.to_msgpack(path_name, metadata, encoding='utf-8')
        packers.to_msgpack(path_name, self.get_dataframe(), encoding='utf-8', compress=n(b'zlib'), append=True)
Ejemplo n.º 2
0
    def test_iterator(self):

        l = [self.frame["float"], self.frame["float"].A, self.frame["float"].B, None]

        with ensure_clean(self.path) as path:
            to_msgpack(path, *l)
            for i, packed in enumerate(read_msgpack(path, iterator=True)):
                check_arbitrary(packed, l[i])
Ejemplo n.º 3
0
    def test_iterator(self):

        packed_items = [self.frame['float'], self.frame['float'].A,
                        self.frame['float'].B, None]

        with ensure_clean(self.path) as path:
            to_msgpack(path, *packed_items)
            for i, packed in enumerate(read_msgpack(path, iterator=True)):
                check_arbitrary(packed, packed_items[i])
Ejemplo n.º 4
0
    def test_iterator_with_string_io(self):

        dfs = [ DataFrame(np.random.randn(10,2)) for i in range(5) ]
        s = to_msgpack(None,*dfs)
        for i, result in enumerate(read_msgpack(s.getvalue(),iterator=True)):
            tm.assert_frame_equal(result,dfs[i])

        s = to_msgpack(None,*dfs)
        for i, result in enumerate(read_msgpack(s,iterator=True)):
            tm.assert_frame_equal(result,dfs[i])
Ejemplo n.º 5
0
    def test_string_io(self):

        df = DataFrame(np.random.randn(10,2))
        s = df.to_msgpack(None)
        result = read_msgpack(s)
        tm.assert_frame_equal(result,df)

        s = df.to_msgpack()
        result = read_msgpack(s)
        tm.assert_frame_equal(result,df)

        s = df.to_msgpack()
        result = read_msgpack(compat.BytesIO(s))
        tm.assert_frame_equal(result,df)

        s = to_msgpack(None,df)
        result = read_msgpack(s)
        tm.assert_frame_equal(result, df)

        with ensure_clean(self.path) as p:

            s = df.to_msgpack()
            fh = open(p,'wb')
            fh.write(s)
            fh.close()
            result = read_msgpack(p)
            tm.assert_frame_equal(result, df)
Ejemplo n.º 6
0
    def test_string_io(self):

        df = DataFrame(np.random.randn(10, 2))
        s = df.to_msgpack(None)
        result = read_msgpack(s)
        tm.assert_frame_equal(result, df)

        s = df.to_msgpack()
        result = read_msgpack(s)
        tm.assert_frame_equal(result, df)

        s = df.to_msgpack()
        result = read_msgpack(BytesIO(s))
        tm.assert_frame_equal(result, df)

        s = to_msgpack(None, df)
        result = read_msgpack(s)
        tm.assert_frame_equal(result, df)

        with ensure_clean(self.path) as p:

            s = df.to_msgpack()
            with open(p, 'wb') as fh:
                fh.write(s)
            result = read_msgpack(p)
            tm.assert_frame_equal(result, df)
Ejemplo n.º 7
0
 def encode_decode(self, x, compress=None, **kwargs):
     with ensure_clean(self.path) as p:
         to_msgpack(p, x, compress=compress, **kwargs)
         return read_msgpack(p, **kwargs)
Ejemplo n.º 8
0
 def encode_decode(self, x, compress=None, **kwargs):
     with ensure_clean(self.path) as p:
         to_msgpack(p, x, compress=compress, **kwargs)
         return read_msgpack(p, **kwargs)
Ejemplo n.º 9
0
    def test_iterator_with_string_io(self):

        dfs = [DataFrame(np.random.randn(10, 2)) for i in range(5)]
        s = to_msgpack(None, *dfs)
        for i, result in enumerate(read_msgpack(s, iterator=True)):
            tm.assert_frame_equal(result, dfs[i])