当前位置: 首页>>代码示例>>Python>>正文


Python testing.round_trip_pickle方法代码示例

本文整理汇总了Python中pandas.util.testing.round_trip_pickle方法的典型用法代码示例。如果您正苦于以下问题:Python testing.round_trip_pickle方法的具体用法?Python testing.round_trip_pickle怎么用?Python testing.round_trip_pickle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pandas.util.testing的用法示例。


在下文中一共展示了testing.round_trip_pickle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_pickle

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import round_trip_pickle [as 别名]
def test_pickle(self):

        # GH4606
        p = tm.round_trip_pickle(NaT)
        assert p is NaT

        idx = pd.to_datetime(['2013-01-01', NaT, '2014-01-06'])
        idx_p = tm.round_trip_pickle(idx)
        assert idx_p[0] == idx[0]
        assert idx_p[1] is NaT
        assert idx_p[2] == idx[2]

        # GH11002
        # don't infer freq
        idx = date_range('1750-1-1', '2050-1-1', freq='7D')
        idx_p = tm.round_trip_pickle(idx)
        tm.assert_index_equal(idx, idx_p) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:19,代码来源:test_timeseries.py

示例2: test_dataframe_metadata

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import round_trip_pickle [as 别名]
def test_dataframe_metadata(self):
        df = tm.SubclassedDataFrame({'X': [1, 2, 3], 'Y': [1, 2, 3]},
                                    index=['a', 'b', 'c'])
        df.testattr = 'XXX'

        assert df.testattr == 'XXX'
        assert df[['X']].testattr == 'XXX'
        assert df.loc[['a', 'b'], :].testattr == 'XXX'
        assert df.iloc[[0, 1], :].testattr == 'XXX'

        # see gh-9776
        assert df.iloc[0:1, :].testattr == 'XXX'

        # see gh-10553
        unpickled = tm.round_trip_pickle(df)
        tm.assert_frame_equal(df, unpickled)
        assert df._metadata == unpickled._metadata
        assert df.testattr == unpickled.testattr 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:20,代码来源:test_subclass.py

示例3: test_pickle

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import round_trip_pickle [as 别名]
def test_pickle(self):
        unpickled = tm.round_trip_pickle(self.panel)
        assert_frame_equal(unpickled['ItemA'], self.panel['ItemA']) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:5,代码来源:test_panel.py

示例4: test_pickle

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import round_trip_pickle [as 别名]
def test_pickle(self):
        def _test_roundtrip(series):
            unpickled = tm.round_trip_pickle(series)
            tm.assert_sp_series_equal(series, unpickled)
            tm.assert_series_equal(series.to_dense(), unpickled.to_dense())

        self._check_all(_test_roundtrip) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:9,代码来源:test_series.py

示例5: test_pickle

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import round_trip_pickle [as 别名]
def test_pickle(self, float_frame, float_frame_int_kind, float_frame_dense,
                    float_frame_fill0, float_frame_fill0_dense,
                    float_frame_fill2, float_frame_fill2_dense):

        def _test_roundtrip(frame, orig):
            result = tm.round_trip_pickle(frame)
            tm.assert_sp_frame_equal(frame, result)
            tm.assert_frame_equal(result.to_dense(), orig, check_dtype=False)

        _test_roundtrip(SparseDataFrame(), DataFrame())
        _test_roundtrip(float_frame, float_frame_dense)
        _test_roundtrip(float_frame_int_kind, float_frame_dense)
        _test_roundtrip(float_frame_fill0, float_frame_fill0_dense)
        _test_roundtrip(float_frame_fill2, float_frame_fill2_dense) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:16,代码来源:test_frame.py

示例6: test_pickle

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import round_trip_pickle [as 别名]
def test_pickle(self):
        def _check(blk):
            assert_block_equal(tm.round_trip_pickle(blk), blk)

        _check(self.fblock)
        _check(self.cblock)
        _check(self.oblock)
        _check(self.bool_block) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:10,代码来源:test_internals.py

示例7: test_categorical_block_pickle

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import round_trip_pickle [as 别名]
def test_categorical_block_pickle(self):
        mgr = create_mgr('a: category')
        mgr2 = tm.round_trip_pickle(mgr)
        assert_frame_equal(DataFrame(mgr), DataFrame(mgr2))

        smgr = create_single_mgr('category')
        smgr2 = tm.round_trip_pickle(smgr)
        assert_series_equal(Series(smgr), Series(smgr2)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:10,代码来源:test_internals.py

示例8: test_pickle

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import round_trip_pickle [as 别名]
def test_pickle(self):
        def _check_roundtrip(obj):
            unpickled = tm.round_trip_pickle(obj)
            tm.assert_sp_array_equal(unpickled, obj)

        _check_roundtrip(self.arr)
        _check_roundtrip(self.zarr) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:9,代码来源:test_array.py

示例9: test_pickle

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import round_trip_pickle [as 别名]
def test_pickle(self):

        rng = timedelta_range('1 days', periods=10)
        rng_p = tm.round_trip_pickle(rng)
        tm.assert_index_equal(rng, rng_p) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,代码来源:test_timedelta.py

示例10: test_pickle

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import round_trip_pickle [as 别名]
def test_pickle(self, indices):
        original_name, indices.name = indices.name, 'foo'
        unpickled = tm.round_trip_pickle(indices)
        assert indices.equals(unpickled)
        indices.name = original_name 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,代码来源:test_common.py

示例11: test_roundtrip_pickle_with_tz

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import round_trip_pickle [as 别名]
def test_roundtrip_pickle_with_tz(self):

        # GH 8367
        # round-trip of timezone
        index = date_range('20130101', periods=3, tz='US/Eastern', name='foo')
        unpickled = tm.round_trip_pickle(index)
        tm.assert_index_equal(index, unpickled) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:9,代码来源:test_datetime.py

示例12: test_pickle_unpickle

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import round_trip_pickle [as 别名]
def test_pickle_unpickle(self):
        unpickled = tm.round_trip_pickle(self.rng)
        assert unpickled.freq is not None 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:5,代码来源:test_ops.py

示例13: test_pickle_round_trip

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import round_trip_pickle [as 别名]
def test_pickle_round_trip(self, freq):
        idx = PeriodIndex(['2016-05-16', 'NaT', NaT, np.NaN], freq=freq)
        result = tm.round_trip_pickle(idx)
        tm.assert_index_equal(result, idx) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:6,代码来源:test_period.py

示例14: test_pickle_freq

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import round_trip_pickle [as 别名]
def test_pickle_freq(self):
        # GH2891
        prng = period_range('1/1/2011', '1/1/2012', freq='M')
        new_prng = tm.round_trip_pickle(prng)
        assert new_prng.freq == offsets.MonthEnd()
        assert new_prng.freqstr == 'M' 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:8,代码来源:test_period.py

示例15: test_roundtrip_pickle_with_tz

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import round_trip_pickle [as 别名]
def test_roundtrip_pickle_with_tz():
    return

    # GH 8367
    # round-trip of timezone
    index = MultiIndex.from_product(
        [[1, 2], ['a', 'b'], date_range('20130101', periods=3,
                                        tz='US/Eastern')
         ], names=['one', 'two', 'three'])
    unpickled = tm.round_trip_pickle(index)
    assert index.equal_levels(unpickled) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:13,代码来源:test_conversion.py


注:本文中的pandas.util.testing.round_trip_pickle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。