當前位置: 首頁>>代碼示例>>Python>>正文


Python pandas.Float64Index方法代碼示例

本文整理匯總了Python中pandas.Float64Index方法的典型用法代碼示例。如果您正苦於以下問題:Python pandas.Float64Index方法的具體用法?Python pandas.Float64Index怎麽用?Python pandas.Float64Index使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pandas的用法示例。


在下文中一共展示了pandas.Float64Index方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_explicit_conversions

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import Float64Index [as 別名]
def test_explicit_conversions(self):

        # GH 8608
        # add/sub are overridden explicitly for Float/Int Index
        idx = RangeIndex(5)

        # float conversions
        arr = np.arange(5, dtype='int64') * 3.2
        expected = Float64Index(arr)
        fidx = idx * 3.2
        tm.assert_index_equal(fidx, expected)
        fidx = 3.2 * idx
        tm.assert_index_equal(fidx, expected)

        # interops with numpy arrays
        expected = Float64Index(arr)
        a = np.zeros(5, dtype='float64')
        result = fidx - a
        tm.assert_index_equal(result, expected)

        expected = Float64Index(-arr)
        a = np.zeros(5, dtype='float64')
        result = a - fidx
        tm.assert_index_equal(result, expected) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:26,代碼來源:test_range.py

示例2: test_explicit_conversions

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import Float64Index [as 別名]
def test_explicit_conversions(self):

        # GH 8608
        # add/sub are overridden explicitly for Float/Int Index
        idx = self._holder(np.arange(5, dtype='int64'))

        # float conversions
        arr = np.arange(5, dtype='int64') * 3.2
        expected = Float64Index(arr)
        fidx = idx * 3.2
        tm.assert_index_equal(fidx, expected)
        fidx = 3.2 * idx
        tm.assert_index_equal(fidx, expected)

        # interops with numpy arrays
        expected = Float64Index(arr)
        a = np.zeros(5, dtype='float64')
        result = fidx - a
        tm.assert_index_equal(result, expected)

        expected = Float64Index(-arr)
        a = np.zeros(5, dtype='float64')
        result = a - fidx
        tm.assert_index_equal(result, expected) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:26,代碼來源:test_numeric.py

示例3: test_get_nan_multiple

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import Float64Index [as 別名]
def test_get_nan_multiple():
    # GH 8569
    # ensure that fixing "test_get_nan" above hasn't broken get
    # with multiple elements
    s = pd.Float64Index(range(10)).to_series()

    idx = [2, 30]
    with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
        assert_series_equal(s.get(idx),
                            Series([2, np.nan], index=idx))

    idx = [2, np.nan]
    with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
        assert_series_equal(s.get(idx),
                            Series([2, np.nan], index=idx))

    # GH 17295 - all missing keys
    idx = [20, 30]
    assert(s.get(idx) is None)

    idx = [np.nan, np.nan]
    assert(s.get(idx) is None) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:24,代碼來源:test_numeric.py

示例4: test_insert

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import Float64Index [as 別名]
def test_insert(self):

        idx = RangeIndex(5, name='Foo')
        result = idx[1:4]

        # test 0th element
        tm.assert_index_equal(idx[0:4], result.insert(0, idx[0]))

        # GH 18295 (test missing)
        expected = Float64Index([0, np.nan, 1, 2, 3, 4])
        for na in (np.nan, pd.NaT, None):
            result = RangeIndex(5).insert(1, na)
            tm.assert_index_equal(result, expected) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:15,代碼來源:test_range.py

示例5: test_append

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import Float64Index [as 別名]
def test_append(self):
        # GH16212
        RI = RangeIndex
        I64 = Int64Index
        F64 = Float64Index
        OI = Index
        cases = [([RI(1, 12, 5)], RI(1, 12, 5)),
                 ([RI(0, 6, 4)], RI(0, 6, 4)),
                 ([RI(1, 3), RI(3, 7)], RI(1, 7)),
                 ([RI(1, 5, 2), RI(5, 6)], RI(1, 6, 2)),
                 ([RI(1, 3, 2), RI(4, 7, 3)], RI(1, 7, 3)),
                 ([RI(-4, 3, 2), RI(4, 7, 2)], RI(-4, 7, 2)),
                 ([RI(-4, -8), RI(-8, -12)], RI(0, 0)),
                 ([RI(-4, -8), RI(3, -4)], RI(0, 0)),
                 ([RI(-4, -8), RI(3, 5)], RI(3, 5)),
                 ([RI(-4, -2), RI(3, 5)], I64([-4, -3, 3, 4])),
                 ([RI(-2,), RI(3, 5)], RI(3, 5)),
                 ([RI(2,), RI(2)], I64([0, 1, 0, 1])),
                 ([RI(2,), RI(2, 5), RI(5, 8, 4)], RI(0, 6)),
                 ([RI(2,), RI(3, 5), RI(5, 8, 4)], I64([0, 1, 3, 4, 5])),
                 ([RI(-2, 2), RI(2, 5), RI(5, 8, 4)], RI(-2, 6)),
                 ([RI(3,), I64([-1, 3, 15])], I64([0, 1, 2, -1, 3, 15])),
                 ([RI(3,), F64([-1, 3.1, 15.])], F64([0, 1, 2, -1, 3.1, 15.])),
                 ([RI(3,), OI(['a', None, 14])], OI([0, 1, 2, 'a', None, 14])),
                 ([RI(3, 1), OI(['a', None, 14])], OI(['a', None, 14]))
                 ]

        for indices, expected in cases:
            result = indices[0].append(indices[1:])
            tm.assert_index_equal(result, expected, exact=True)

            if len(indices) == 2:
                # Append single item rather than list
                result2 = indices[0].append(indices[1])
                tm.assert_index_equal(result2, expected, exact=True) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:37,代碼來源:test_range.py

示例6: test_constructor_int_dtype_nan

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import Float64Index [as 別名]
def test_constructor_int_dtype_nan(self):
        # see gh-15187
        data = [np.nan]
        expected = Float64Index(data)
        result = Index(data, dtype='float')
        tm.assert_index_equal(result, expected) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:8,代碼來源:test_base.py

示例7: test_isin_nan_common_float64

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import Float64Index [as 別名]
def test_isin_nan_common_float64(self, nulls_fixture):
        if nulls_fixture is pd.NaT:
            pytest.skip("pd.NaT not compatible with Float64Index")

        # Float64Index overrides isin, so must be checked separately
        tm.assert_numpy_array_equal(Float64Index([1.0, nulls_fixture]).isin(
            [np.nan]), np.array([False, True]))

        # we cannot compare NaT with NaN
        tm.assert_numpy_array_equal(Float64Index([1.0, nulls_fixture]).isin(
            [pd.NaT]), np.array([False, False])) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:13,代碼來源:test_base.py

示例8: test_reindex_no_type_preserve_target_empty_mi

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import Float64Index [as 別名]
def test_reindex_no_type_preserve_target_empty_mi(self):
        index = pd.Index(list('abc'))
        result = index.reindex(pd.MultiIndex(
            [pd.Int64Index([]), pd.Float64Index([])], [[], []]))[0]
        assert result.levels[0].dtype.type == np.int64
        assert result.levels[1].dtype.type == np.float64 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:8,代碼來源:test_base.py

示例9: test_where

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import Float64Index [as 別名]
def test_where(self, klass):
        i = self.create_index()
        cond = [True] * len(i)
        expected = i
        result = i.where(klass(cond))

        cond = [False] + [True] * (len(i) - 1)
        expected = Float64Index([i._na_value] + i[1:].tolist())
        result = i.where(klass(cond))
        tm.assert_index_equal(result, expected) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:12,代碼來源:test_numeric.py

示例10: setup_method

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import Float64Index [as 別名]
def setup_method(self, method):
        self.indices = dict(mixed=Float64Index([1.5, 2, 3, 4, 5]),
                            float=Float64Index(np.arange(5) * 2.5),
                            mixed_dec=Float64Index([5, 4, 3, 2, 1.5]),
                            float_dec=Float64Index(np.arange(4, -1, -1) * 2.5))
        self.setup_indices() 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:8,代碼來源:test_numeric.py

示例11: create_index

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import Float64Index [as 別名]
def create_index(self):
        return Float64Index(np.arange(5, dtype='float64')) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:4,代碼來源:test_numeric.py

示例12: check_is_index

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import Float64Index [as 別名]
def check_is_index(self, i):
        assert isinstance(i, Index)
        assert not isinstance(i, Float64Index) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:5,代碼來源:test_numeric.py

示例13: check_coerce

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import Float64Index [as 別名]
def check_coerce(self, a, b, is_float_index=True):
        assert a.equals(b)
        tm.assert_index_equal(a, b, exact=False)
        if is_float_index:
            assert isinstance(b, Float64Index)
        else:
            self.check_is_index(b) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:9,代碼來源:test_numeric.py

示例14: test_constructor

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import Float64Index [as 別名]
def test_constructor(self):

        # explicit construction
        index = Float64Index([1, 2, 3, 4, 5])
        assert isinstance(index, Float64Index)
        expected = np.array([1, 2, 3, 4, 5], dtype='float64')
        tm.assert_numpy_array_equal(index.values, expected)
        index = Float64Index(np.array([1, 2, 3, 4, 5]))
        assert isinstance(index, Float64Index)
        index = Float64Index([1., 2, 3, 4, 5])
        assert isinstance(index, Float64Index)
        index = Float64Index(np.array([1., 2, 3, 4, 5]))
        assert isinstance(index, Float64Index)
        assert index.dtype == float

        index = Float64Index(np.array([1., 2, 3, 4, 5]), dtype=np.float32)
        assert isinstance(index, Float64Index)
        assert index.dtype == np.float64

        index = Float64Index(np.array([1, 2, 3, 4, 5]), dtype=np.float32)
        assert isinstance(index, Float64Index)
        assert index.dtype == np.float64

        # nan handling
        result = Float64Index([np.nan, np.nan])
        assert pd.isna(result.values).all()
        result = Float64Index(np.array([np.nan]))
        assert pd.isna(result.values).all()
        result = Index(np.array([np.nan]))
        assert pd.isna(result.values).all() 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:32,代碼來源:test_numeric.py

示例15: test_type_coercion_valid

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import Float64Index [as 別名]
def test_type_coercion_valid(self, float_dtype):
        # There is no Float32Index, so we always
        # generate Float64Index.
        i = Index([1, 2, 3.5], dtype=float_dtype)
        tm.assert_index_equal(i, Index([1, 2, 3.5])) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:7,代碼來源:test_numeric.py


注:本文中的pandas.Float64Index方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。