本文整理匯總了Python中pandas.util.testing.assert_copy方法的典型用法代碼示例。如果您正苦於以下問題:Python testing.assert_copy方法的具體用法?Python testing.assert_copy怎麽用?Python testing.assert_copy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pandas.util.testing
的用法示例。
在下文中一共展示了testing.assert_copy方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: assert_multiindex_copied
# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import assert_copy [as 別名]
def assert_multiindex_copied(copy, original):
# Levels should be (at least, shallow copied)
tm.assert_copy(copy.levels, original.levels)
tm.assert_almost_equal(copy.codes, original.codes)
# Labels doesn't matter which way copied
tm.assert_almost_equal(copy.codes, original.codes)
assert copy.codes is not original.codes
# Names doesn't matter which way copied
assert copy.names == original.names
assert copy.names is not original.names
# Sort order should be copied
assert copy.sortorder == original.sortorder
示例2: test_astype
# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import assert_copy [as 別名]
def test_astype(self):
expected = self.index.copy()
actual = self.index.astype('O')
assert_copy(actual.levels, expected.levels)
assert_copy(actual.labels, expected.labels)
self.check_level_names(actual, expected.names)
with tm.assert_raises_regex(TypeError, "^Setting.*dtype.*object"):
self.index.astype(np.dtype(int))
示例3: assert_multiindex_copied
# 需要導入模塊: from pandas.util import testing [as 別名]
# 或者: from pandas.util.testing import assert_copy [as 別名]
def assert_multiindex_copied(self, copy, original):
# Levels should be (at least, shallow copied)
tm.assert_copy(copy.levels, original.levels)
tm.assert_almost_equal(copy.labels, original.labels)
# Labels doesn't matter which way copied
tm.assert_almost_equal(copy.labels, original.labels)
assert copy.labels is not original.labels
# Names doesn't matter which way copied
assert copy.names == original.names
assert copy.names is not original.names
# Sort order should be copied
assert copy.sortorder == original.sortorder