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


Python IntervalArray.from_breaks方法代码示例

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


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

示例1: test_get_numeric_data_extension_dtype

# 需要导入模块: from pandas.core.arrays import IntervalArray [as 别名]
# 或者: from pandas.core.arrays.IntervalArray import from_breaks [as 别名]
 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,代码行数:12,代码来源:test_block_internals.py

示例2: test_where_raises

# 需要导入模块: from pandas.core.arrays import IntervalArray [as 别名]
# 或者: from pandas.core.arrays.IntervalArray import from_breaks [as 别名]
 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,代码行数:8,代码来源:test_interval.py

示例3: test_set_closed

# 需要导入模块: from pandas.core.arrays import IntervalArray [as 别名]
# 或者: from pandas.core.arrays.IntervalArray import from_breaks [as 别名]
 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,代码行数:8,代码来源:test_interval.py

示例4: test_repeat_errors

# 需要导入模块: from pandas.core.arrays import IntervalArray [as 别名]
# 或者: from pandas.core.arrays.IntervalArray import from_breaks [as 别名]
 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,代码行数:6,代码来源:test_interval.py

示例5: test_repeat_errors

# 需要导入模块: from pandas.core.arrays import IntervalArray [as 别名]
# 或者: from pandas.core.arrays.IntervalArray import from_breaks [as 别名]
 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,代码行数:6,代码来源:test_interval.py


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