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


Python arrays.IntervalArray類代碼示例

本文整理匯總了Python中pandas.core.arrays.IntervalArray的典型用法代碼示例。如果您正苦於以下問題:Python IntervalArray類的具體用法?Python IntervalArray怎麽用?Python IntervalArray使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: test_set_na

    def test_set_na(self, left_right_dtypes):
        left, right = left_right_dtypes
        result = IntervalArray.from_arrays(left, right)
        result[0] = np.nan

        expected_left = Index([left._na_value] + list(left[1:]))
        expected_right = Index([right._na_value] + list(right[1:]))
        expected = IntervalArray.from_arrays(expected_left, expected_right)

        tm.assert_extension_array_equal(result, expected)
開發者ID:DusanMilunovic,項目名稱:pandas,代碼行數:10,代碼來源:test_interval.py

示例2: test_get_numeric_data_extension_dtype

 def test_get_numeric_data_extension_dtype(self):
     # GH 22290
     df = DataFrame({
         'A': integer_array([-10, np.nan, 0, 10, 20, 30], dtype='Int64'),
         'B': Categorical(list('abcabc')),
         'C': integer_array([0, 1, 2, 3, np.nan, 5], dtype='UInt8'),
         'D': IntervalArray.from_breaks(range(7))})
     result = df._get_numeric_data()
     expected = df.loc[:, ['A', 'C']]
     assert_frame_equal(result, expected)
開發者ID:clham,項目名稱:pandas,代碼行數:10,代碼來源:test_block_internals.py

示例3: test_where_raises

 def test_where_raises(self, other):
     ser = pd.Series(IntervalArray.from_breaks([1, 2, 3, 4],
                                               closed='left'))
     match = "'value.closed' is 'right', expected 'left'."
     with pytest.raises(ValueError, match=match):
         ser.where([True, False, True], other=other)
開發者ID:DusanMilunovic,項目名稱:pandas,代碼行數:6,代碼來源:test_interval.py

示例4: test_set_closed

 def test_set_closed(self, closed, new_closed):
     # GH 21670
     array = IntervalArray.from_breaks(range(10), closed=closed)
     result = array.set_closed(new_closed)
     expected = IntervalArray.from_breaks(range(10), closed=new_closed)
     tm.assert_extension_array_equal(result, expected)
開發者ID:DusanMilunovic,項目名稱:pandas,代碼行數:6,代碼來源:test_interval.py

示例5: data_missing_for_sorting

def data_missing_for_sorting():
    return IntervalArray.from_tuples([(1, 2), None, (0, 1)])
開發者ID:bkandel,項目名稱:pandas,代碼行數:2,代碼來源:test_interval.py

示例6: data_for_grouping

def data_for_grouping():
    a = (0, 1)
    b = (1, 2)
    c = (2, 3)
    return IntervalArray.from_tuples([b, b, None, None, a, a, b, c])
開發者ID:bkandel,項目名稱:pandas,代碼行數:5,代碼來源:test_interval.py

示例7: data_for_sorting

def data_for_sorting():
    return IntervalArray.from_tuples([(1, 2), (2, 3), (0, 1)])
開發者ID:bkandel,項目名稱:pandas,代碼行數:2,代碼來源:test_interval.py

示例8: data_missing

def data_missing():
    """Length 2 array with [NA, Valid]"""
    return IntervalArray.from_tuples([None, (0, 1)])
開發者ID:bkandel,項目名稱:pandas,代碼行數:3,代碼來源:test_interval.py

示例9: test_repeat_errors

 def test_repeat_errors(self, bad_repeats, msg):
     array = IntervalArray.from_breaks(range(4))
     with pytest.raises(ValueError, match=msg):
         array.repeat(bad_repeats)
開發者ID:christlc,項目名稱:pandas,代碼行數:4,代碼來源:test_interval.py

示例10: test_repeat

 def test_repeat(self, left_right_dtypes, repeats):
     left, right = left_right_dtypes
     result = IntervalArray.from_arrays(left, right).repeat(repeats)
     expected = IntervalArray.from_arrays(
         left.repeat(repeats), right.repeat(repeats))
     tm.assert_extension_array_equal(result, expected)
開發者ID:christlc,項目名稱:pandas,代碼行數:6,代碼來源:test_interval.py

示例11: test_repeat_errors

 def test_repeat_errors(self, bad_repeats, msg):
     array = IntervalArray.from_breaks(range(4))
     with tm.assert_raises_regex(ValueError, msg):
         array.repeat(bad_repeats)
開發者ID:Peque,項目名稱:pandas,代碼行數:4,代碼來源:test_interval.py


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