def test_compression_blosc(self): try: import blosc except ImportError: raise nose.SkipTest('no blosc') i_rec = self.encode_decode(self.frame, compress='blosc') for k in self.frame.keys(): assert_frame_equal(self.frame[k], i_rec[k])
def test_compression_blosc(self): try: import blosc except ImportError: raise nose.SkipTest("no blosc") i_rec = self.encode_decode(self.frame, compress="blosc") for k in self.frame.keys(): assert_frame_equal(self.frame[k], i_rec[k])
def tests_datetimeindex_freq_issue(self): # GH 5947 # inferring freq on the datetimeindex df = DataFrame([1, 2, 3], index=date_range('1/1/2013', '1/3/2013')) result = self.encode_decode(df) assert_frame_equal(result, df) df = DataFrame([1, 2], index=date_range('1/1/2013', '1/2/2013')) result = self.encode_decode(df) assert_frame_equal(result, df)
def tests_datetimeindex_freq_issue(self): # GH 5947 # inferring freq on the datetimeindex df = DataFrame([1, 2, 3], index=date_range("1/1/2013", "1/3/2013")) result = self.encode_decode(df) assert_frame_equal(result, df) df = DataFrame([1, 2], index=date_range("1/1/2013", "1/2/2013")) result = self.encode_decode(df) assert_frame_equal(result, df)
def check_arbitrary(a, b): if isinstance(a, (list, tuple)) and isinstance(b, (list, tuple)): assert (len(a) == len(b)) for a_, b_ in zip(a, b): check_arbitrary(a_, b_) elif isinstance(a, Panel): assert_panel_equal(a, b) elif isinstance(a, DataFrame): assert_frame_equal(a, b) elif isinstance(a, Series): assert_series_equal(a, b) else: assert (a == b)
def check_arbitrary(a, b): if isinstance(a, (list, tuple)) and isinstance(b, (list, tuple)): assert(len(a) == len(b)) for a_, b_ in zip(a, b): check_arbitrary(a_, b_) elif isinstance(a, Panel): assert_panel_equal(a, b) elif isinstance(a, DataFrame): assert_frame_equal(a, b) elif isinstance(a, Series): assert_series_equal(a, b) else: assert(a == b)
def test_multi(self): i_rec = self.encode_decode(self.frame) for k in self.frame.keys(): assert_frame_equal(self.frame[k], i_rec[k]) l = tuple([self.frame["float"], self.frame["float"].A, self.frame["float"].B, None]) l_rec = self.encode_decode(l) check_arbitrary(l, l_rec) # this is an oddity in that packed lists will be returned as tuples l = [self.frame["float"], self.frame["float"].A, self.frame["float"].B, None] l_rec = self.encode_decode(l) self.assertIsInstance(l_rec, tuple) check_arbitrary(l, l_rec)
def test_multi(self): i_rec = self.encode_decode(self.frame) for k in self.frame.keys(): assert_frame_equal(self.frame[k], i_rec[k]) l = tuple( [self.frame['float'], self.frame['float'].A, self.frame['float'].B, None]) l_rec = self.encode_decode(l) check_arbitrary(l, l_rec) # this is an oddity in that packed lists will be returned as tuples l = [self.frame['float'], self.frame['float'] .A, self.frame['float'].B, None] l_rec = self.encode_decode(l) self.assertIsInstance(l_rec, tuple) check_arbitrary(l, l_rec)
def test_tseries_indices_frame(self): idx = tm.makeDateIndex(10) df = DataFrame(np.random.randn(len(idx), 3), index=idx) self.store['a'] = df result = self.store['a'] assert_frame_equal(result, df) self.assertEquals(type(result.index), type(df.index)) self.assertEquals(result.index.freq, df.index.freq) idx = tm.makePeriodIndex(10) df = DataFrame(np.random.randn(len(idx), 3), idx) self.store['a'] = df result = self.store['a'] assert_frame_equal(result, df) self.assertEquals(type(result.index), type(df.index)) self.assertEquals(result.index.freq, df.index.freq)
def test_dataframe_duplicate_column_names(self): # GH 9618 expected_1 = DataFrame(columns=['a', 'a']) expected_2 = DataFrame(columns=[1] * 100) expected_2.loc[0] = np.random.randn(100) expected_3 = DataFrame(columns=[1, 1]) expected_3.loc[0] = ['abc', np.nan] result_1 = self.encode_decode(expected_1) result_2 = self.encode_decode(expected_2) result_3 = self.encode_decode(expected_3) assert_frame_equal(result_1, expected_1) assert_frame_equal(result_2, expected_2) assert_frame_equal(result_3, expected_3)
def test_dataframe_duplicate_column_names(self): # GH 9618 expected_1 = DataFrame(columns=["a", "a"]) expected_2 = DataFrame(columns=[1] * 100) expected_2.loc[0] = np.random.randn(100) expected_3 = DataFrame(columns=[1, 1]) expected_3.loc[0] = ["abc", np.nan] result_1 = self.encode_decode(expected_1) result_2 = self.encode_decode(expected_2) result_3 = self.encode_decode(expected_3) assert_frame_equal(result_1, expected_1) assert_frame_equal(result_2, expected_2) assert_frame_equal(result_3, expected_3)
def test_utf(self): # GH10581 for encoding in self.utf_encodings: for frame in compat.itervalues(self.frame): result = self.encode_decode(frame, encoding=encoding) assert_frame_equal(result, frame)
def test_compression_zlib(self): i_rec = self.encode_decode(self.frame, compress="zlib") for k in self.frame.keys(): assert_frame_equal(self.frame[k], i_rec[k])
def test_plain(self): i_rec = self.encode_decode(self.frame) for k in self.frame.keys(): assert_frame_equal(self.frame[k], i_rec[k])
def test_compression_zlib(self): i_rec = self.encode_decode(self.frame, compress='zlib') for k in self.frame.keys(): assert_frame_equal(self.frame[k], i_rec[k])
def test_basic_frame(self): for s, i in self.frame.items(): i_rec = self.encode_decode(i) assert_frame_equal(i, i_rec)
def test_compression_blosc(self): i_rec = self.encode_decode(self.frame, compress='blosc') for k in self.frame.keys(): assert_frame_equal(self.frame[k], i_rec[k])