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


Python common.is_float_dtype方法代码示例

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


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

示例1: test_set_value

# 需要导入模块: from pandas.core.dtypes import common [as 别名]
# 或者: from pandas.core.dtypes.common import is_float_dtype [as 别名]
def test_set_value(self):
        for item in self.panel.items:
            for mjr in self.panel.major_axis[::2]:
                for mnr in self.panel.minor_axis:
                    with tm.assert_produces_warning(FutureWarning,
                                                    check_stacklevel=False):
                        self.panel.set_value(item, mjr, mnr, 1.)
                    tm.assert_almost_equal(self.panel[item][mnr][mjr], 1.)

        # resize
        with catch_warnings():
            simplefilter("ignore", FutureWarning)
            res = self.panel.set_value('ItemE', 'foo', 'bar', 1.5)
            assert isinstance(res, Panel)
            assert res is not self.panel
            assert res.get_value('ItemE', 'foo', 'bar') == 1.5

            res3 = self.panel.set_value('ItemE', 'foobar', 'baz', 5)
            assert is_float_dtype(res3['ItemE'].values)

            msg = ("There must be an argument for each "
                   "axis plus the value provided")
            with pytest.raises(TypeError, match=msg):
                self.panel.set_value('a') 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:26,代码来源:test_panel.py

示例2: test_set_value

# 需要导入模块: from pandas.core.dtypes import common [as 别名]
# 或者: from pandas.core.dtypes.common import is_float_dtype [as 别名]
def test_set_value(self):
        with catch_warnings(record=True):
            for item in self.panel.items:
                for mjr in self.panel.major_axis[::2]:
                    for mnr in self.panel.minor_axis:
                        self.panel.set_value(item, mjr, mnr, 1.)
                        tm.assert_almost_equal(self.panel[item][mnr][mjr], 1.)

            # resize
            res = self.panel.set_value('ItemE', 'foo', 'bar', 1.5)
            assert isinstance(res, Panel)
            assert res is not self.panel
            assert res.get_value('ItemE', 'foo', 'bar') == 1.5

            res3 = self.panel.set_value('ItemE', 'foobar', 'baz', 5)
            assert is_float_dtype(res3['ItemE'].values)

            msg = ("There must be an argument for each "
                   "axis plus the value provided")
            with tm.assert_raises_regex(TypeError, msg):
                self.panel.set_value('a') 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:23,代码来源:test_panel.py

示例3: test_set_value

# 需要导入模块: from pandas.core.dtypes import common [as 别名]
# 或者: from pandas.core.dtypes.common import is_float_dtype [as 别名]
def test_set_value(self):

        with catch_warnings(record=True):

            for label in self.panel4d.labels:
                for item in self.panel4d.items:
                    for mjr in self.panel4d.major_axis[::2]:
                        for mnr in self.panel4d.minor_axis:
                            self.panel4d.set_value(label, item, mjr, mnr, 1.)
                            tm.assert_almost_equal(
                                self.panel4d[label][item][mnr][mjr], 1.)

            res3 = self.panel4d.set_value('l4', 'ItemE', 'foobar', 'baz', 5)
            assert is_float_dtype(res3['l4'].values)

            # resize
            res = self.panel4d.set_value('l4', 'ItemE', 'foo', 'bar', 1.5)
            assert isinstance(res, Panel4D)
            assert res is not self.panel4d
            assert res.get_value('l4', 'ItemE', 'foo', 'bar') == 1.5

            res3 = self.panel4d.set_value('l4', 'ItemE', 'foobar', 'baz', 5)
            assert is_float_dtype(res3['l4'].values) 
开发者ID:securityclippy,项目名称:elasticintel,代码行数:25,代码来源:test_panel4d.py

示例4: test_delevel_infer_dtype

# 需要导入模块: from pandas.core.dtypes import common [as 别名]
# 或者: from pandas.core.dtypes.common import is_float_dtype [as 别名]
def test_delevel_infer_dtype(self):
        tuples = [tuple
                  for tuple in cart_product(
                      ['foo', 'bar'], [10, 20], [1.0, 1.1])]
        index = MultiIndex.from_tuples(tuples, names=['prm0', 'prm1', 'prm2'])
        df = DataFrame(np.random.randn(8, 3), columns=['A', 'B', 'C'],
                       index=index)
        deleveled = df.reset_index()
        assert is_integer_dtype(deleveled['prm1'])
        assert is_float_dtype(deleveled['prm2']) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:12,代码来源:test_multilevel.py

示例5: test_setitem_dtype_upcast

# 需要导入模块: from pandas.core.dtypes import common [as 别名]
# 或者: from pandas.core.dtypes.common import is_float_dtype [as 别名]
def test_setitem_dtype_upcast(self):

        # GH3216
        df = DataFrame([{"a": 1}, {"a": 3, "b": 2}])
        df['c'] = np.nan
        assert df['c'].dtype == np.float64

        df.loc[0, 'c'] = 'foo'
        expected = DataFrame([{"a": 1, "c": 'foo'},
                              {"a": 3, "b": 2, "c": np.nan}])
        tm.assert_frame_equal(df, expected)

        # GH10280
        df = DataFrame(np.arange(6, dtype='int64').reshape(2, 3),
                       index=list('ab'),
                       columns=['foo', 'bar', 'baz'])

        for val in [3.14, 'wxyz']:
            left = df.copy()
            left.loc['a', 'bar'] = val
            right = DataFrame([[0, val, 2], [3, 4, 5]], index=list('ab'),
                              columns=['foo', 'bar', 'baz'])

            tm.assert_frame_equal(left, right)
            assert is_integer_dtype(left['foo'])
            assert is_integer_dtype(left['baz'])

        left = DataFrame(np.arange(6, dtype='int64').reshape(2, 3) / 10.0,
                         index=list('ab'),
                         columns=['foo', 'bar', 'baz'])
        left.loc['a', 'bar'] = 'wxyz'

        right = DataFrame([[0, 'wxyz', .2], [.3, .4, .5]], index=list('ab'),
                          columns=['foo', 'bar', 'baz'])

        tm.assert_frame_equal(left, right)
        assert is_float_dtype(left['foo'])
        assert is_float_dtype(left['baz']) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:40,代码来源:test_indexing.py

示例6: test_set_value_resize

# 需要导入模块: from pandas.core.dtypes import common [as 别名]
# 或者: from pandas.core.dtypes.common import is_float_dtype [as 别名]
def test_set_value_resize(self):

        with tm.assert_produces_warning(FutureWarning,
                                        check_stacklevel=False):
            res = self.frame.set_value('foobar', 'B', 0)
        assert res is self.frame
        assert res.index[-1] == 'foobar'
        with tm.assert_produces_warning(FutureWarning,
                                        check_stacklevel=False):
            assert res.get_value('foobar', 'B') == 0

        self.frame.loc['foobar', 'qux'] = 0
        with tm.assert_produces_warning(FutureWarning,
                                        check_stacklevel=False):
            assert self.frame.get_value('foobar', 'qux') == 0

        res = self.frame.copy()
        with tm.assert_produces_warning(FutureWarning,
                                        check_stacklevel=False):
            res3 = res.set_value('foobar', 'baz', 'sam')
        assert res3['baz'].dtype == np.object_

        res = self.frame.copy()
        with tm.assert_produces_warning(FutureWarning,
                                        check_stacklevel=False):
            res3 = res.set_value('foobar', 'baz', True)
        assert res3['baz'].dtype == np.object_

        res = self.frame.copy()
        with tm.assert_produces_warning(FutureWarning,
                                        check_stacklevel=False):
            res3 = res.set_value('foobar', 'baz', 5)
        assert is_float_dtype(res3['baz'])
        assert isna(res3['baz'].drop(['foobar'])).all()
        with tm.assert_produces_warning(FutureWarning,
                                        check_stacklevel=False):
            pytest.raises(ValueError, res3.set_value, 'foobar', 'baz', 'sam') 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:39,代码来源:test_indexing.py

示例7: test_is_float_dtype

# 需要导入模块: from pandas.core.dtypes import common [as 别名]
# 或者: from pandas.core.dtypes.common import is_float_dtype [as 别名]
def test_is_float_dtype():
    assert not com.is_float_dtype(str)
    assert not com.is_float_dtype(int)
    assert not com.is_float_dtype(pd.Series([1, 2]))
    assert not com.is_float_dtype(np.array(['a', 'b']))

    assert com.is_float_dtype(float)
    assert com.is_float_dtype(pd.Index([1, 2.])) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:10,代码来源:test_common.py


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