本文整理汇总了Python中pandas.core.base.FrozenNDArray.values方法的典型用法代码示例。如果您正苦于以下问题:Python FrozenNDArray.values方法的具体用法?Python FrozenNDArray.values怎么用?Python FrozenNDArray.values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandas.core.base.FrozenNDArray
的用法示例。
在下文中一共展示了FrozenNDArray.values方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestFrozenNDArray
# 需要导入模块: from pandas.core.base import FrozenNDArray [as 别名]
# 或者: from pandas.core.base.FrozenNDArray import values [as 别名]
class TestFrozenNDArray(CheckImmutable, CheckStringMixin, tm.TestCase):
mutable_methods = ('put', 'itemset', 'fill')
unicode_container = FrozenNDArray([u("\u05d0"), u("\u05d1"), "c"])
def setUp(self):
self.lst = [3, 5, 7, -2]
self.container = FrozenNDArray(self.lst)
self.klass = FrozenNDArray
def test_shallow_copying(self):
original = self.container.copy()
self.assertIsInstance(self.container.view(), FrozenNDArray)
self.assertFalse(isinstance(
self.container.view(np.ndarray), FrozenNDArray))
self.assertIsNot(self.container.view(), self.container)
self.assert_numpy_array_equal(self.container, original)
# shallow copy should be the same too
self.assertIsInstance(self.container._shallow_copy(), FrozenNDArray)
# setting should not be allowed
def testit(container):
container[0] = 16
self.check_mutable_error(testit, self.container)
def test_values(self):
original = self.container.view(np.ndarray).copy()
n = original[0] + 15
vals = self.container.values()
self.assert_numpy_array_equal(original, vals)
self.assertIsNot(original, vals)
vals[0] = n
self.assertIsInstance(self.container, pd.core.base.FrozenNDArray)
self.assert_numpy_array_equal(self.container.values(), original)
self.assertEqual(vals[0], n)
示例2: TestFrozenNDArray
# 需要导入模块: from pandas.core.base import FrozenNDArray [as 别名]
# 或者: from pandas.core.base.FrozenNDArray import values [as 别名]
class TestFrozenNDArray(CheckImmutable, unittest.TestCase):
mutable_methods = ('put', 'itemset', 'fill')
def setUp(self):
self.lst = [3, 5, 7, -2]
self.container = FrozenNDArray(self.lst)
self.klass = FrozenNDArray
def test_shallow_copying(self):
original = self.container.copy()
assert_isinstance(self.container.view(), FrozenNDArray)
self.assert_(not isinstance(self.container.view(np.ndarray), FrozenNDArray))
self.assert_(self.container.view() is not self.container)
self.assert_(np.array_equal(self.container, original))
# shallow copy should be the same too
assert_isinstance(self.container._shallow_copy(), FrozenNDArray)
# setting should not be allowed
def testit(container): container[0] = 16
self.check_mutable_error(testit, self.container)
def test_values(self):
original = self.container.view(np.ndarray).copy()
n = original[0] + 15
vals = self.container.values()
self.assert_(np.array_equal(original, vals))
self.assert_(original is not vals)
vals[0] = n
self.assert_(np.array_equal(self.container, original))
self.assertEqual(vals[0], n)