本文整理汇总了Python中pandas.api.types.is_float_dtype方法的典型用法代码示例。如果您正苦于以下问题:Python types.is_float_dtype方法的具体用法?Python types.is_float_dtype怎么用?Python types.is_float_dtype使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandas.api.types
的用法示例。
在下文中一共展示了types.is_float_dtype方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_scale
# 需要导入模块: from pandas.api import types [as 别名]
# 或者: from pandas.api.types import is_float_dtype [as 别名]
def make_scale(ae, series, *args, **kwargs):
"""
Return a proper scale object for the series
The scale is for the aesthetic ae, and args & kwargs
are passed on to the scale creating class
"""
if pdtypes.is_float_dtype(series) and np.isinf(series).all():
raise PlotnineError("Cannot create scale for infinite data")
stype = scale_type(series)
# filter parameters by scale type
if stype in ('discrete', 'ordinal'):
with suppress(KeyError):
del kwargs['trans']
scale_name = 'scale_{}_{}'.format(ae, stype)
scale_klass = Registry[scale_name]
return scale_klass(*args, **kwargs)
示例2: test_cload_field
# 需要导入模块: from pandas.api import types [as 别名]
# 或者: from pandas.api.types import is_float_dtype [as 别名]
def test_cload_field(bins_path, pairs_path):
kwargs = dict(
metadata=None,
assembly="toy",
chunksize=10,
zero_based=False,
comment_char="#",
input_copy_status="unique",
no_symmetric_upper=False,
temp_dir=None,
no_delete_temp=False,
storage_options=None,
no_count=True,
max_merge=200,
chrom1=2,
pos1=3,
chrom2=4,
pos2=5,
)
cload_pairs.callback(
bins_path, pairs_path, testcool_path, field=("score=8:dtype=float",), **kwargs
)
pixels = cooler.Cooler(testcool_path).pixels()[:]
assert "count" in pixels.columns and types.is_integer_dtype(pixels.dtypes["count"])
assert "score" in pixels.columns and types.is_float_dtype(pixels.dtypes["score"])
示例3: _check_op
# 需要导入模块: from pandas.api import types [as 别名]
# 或者: from pandas.api.types import is_float_dtype [as 别名]
def _check_op(self, s, op_name, other, exc=None):
op = self.get_op_from_name(op_name)
result = op(s, other)
# compute expected
mask = s.isna()
# if s is a DataFrame, squeeze to a Series
# for comparison
if isinstance(s, pd.DataFrame):
result = result.squeeze()
s = s.squeeze()
mask = mask.squeeze()
# other array is an Integer
if isinstance(other, IntegerArray):
omask = getattr(other, 'mask', None)
mask = getattr(other, 'data', other)
if omask is not None:
mask |= omask
# 1 ** na is na, so need to unmask those
if op_name == '__pow__':
mask = np.where(s == 1, False, mask)
elif op_name == '__rpow__':
mask = np.where(other == 1, False, mask)
# float result type or float op
if ((is_float_dtype(other) or is_float(other) or
op_name in ['__rtruediv__', '__truediv__',
'__rdiv__', '__div__'])):
rs = s.astype('float')
expected = op(rs, other)
self._check_op_float(result, expected, mask, s, op_name, other)
# integer result type
else:
rs = pd.Series(s.values._data)
expected = op(rs, other)
self._check_op_integer(result, expected, mask, s, op_name, other)
示例4: test_dataframe
# 需要导入模块: from pandas.api import types [as 别名]
# 或者: from pandas.api.types import is_float_dtype [as 别名]
def test_dataframe():
d2 = DirectAccessV2(
api_key=DIRECTACCESS_API_KEY,
client_id=DIRECTACCESS_CLIENT_ID,
client_secret=DIRECTACCESS_CLIENT_SECRET,
access_token=DIRECTACCESS_TOKEN,
)
df = d2.to_dataframe("rigs", pagesize=10000, deleteddate="null")
# Check index is set to API endpoint "primary key"
assert df.index.name == "RigID"
# Check datetime64 dtypes
assert is_datetime64_ns_dtype(df.CreatedDate)
assert is_datetime64_ns_dtype(df.DeletedDate)
assert is_datetime64_ns_dtype(df.SpudDate)
assert is_datetime64_ns_dtype(df.UpdatedDate)
# Check Int64 dtypes
assert is_int64_dtype(df.PermitDepth)
assert is_int64_dtype(df.FormationDepth)
# Check float dtypes
assert is_float_dtype(df.RigLatitudeWGS84)
assert is_float_dtype(df.RigLongitudeWGS84)
return
示例5: test_load_field
# 需要导入模块: from pandas.api import types [as 别名]
# 或者: from pandas.api.types import is_float_dtype [as 别名]
def test_load_field():
runner = CliRunner()
with runner.isolated_filesystem():
extra_args = ["--field", "count=7:dtype=float"]
result = _run_load(runner, "toy.symm.upper.2.bg2", "bg2", 2, extra_args)
assert result.exit_code == 0
pixels1 = cooler.Cooler(op.join(datadir, "toy.symm.upper.2.cool")).pixels()[:]
pixels2 = cooler.Cooler("toy.2.cool").pixels()[:]
assert "count" in pixels2.columns and types.is_float_dtype(
pixels2.dtypes["count"]
)
assert np.allclose(pixels1["count"][:], pixels2["count"][:])
示例6: test_load_field2
# 需要导入模块: from pandas.api import types [as 别名]
# 或者: from pandas.api.types import is_float_dtype [as 别名]
def test_load_field2():
runner = CliRunner()
with runner.isolated_filesystem():
extra_args = ["--count-as-float"]
result = _run_load(runner, "toy.symm.upper.2.bg2", "bg2", 2, extra_args)
assert result.exit_code == 0
pixels1 = cooler.Cooler(op.join(datadir, "toy.symm.upper.2.cool")).pixels()[:]
pixels2 = cooler.Cooler("toy.2.cool").pixels()[:]
assert "count" in pixels2.columns and types.is_float_dtype(
pixels2.dtypes["count"]
)
assert np.allclose(pixels1["count"][:], pixels2["count"][:])
示例7: test_cload_field
# 需要导入模块: from pandas.api import types [as 别名]
# 或者: from pandas.api.types import is_float_dtype [as 别名]
def test_cload_field():
runner = CliRunner()
with runner.isolated_filesystem():
extra_args = ["--field", "score=8"]
result = _run_cload_pairs(runner, 2, extra_args)
assert result.exit_code == 0
pixels = cooler.Cooler("toy.2.cool").pixels()[:]
assert "count" in pixels.columns and types.is_integer_dtype(
pixels.dtypes["count"]
)
assert "score" in pixels.columns and types.is_float_dtype(
pixels.dtypes["score"]
)
extra_args = ["--field", "count=8"]
result = _run_cload_pairs(runner, 2, extra_args)
assert result.exit_code == 0
pixels = cooler.Cooler("toy.2.cool").pixels()[:]
assert "count" in pixels.columns and types.is_integer_dtype(
pixels.dtypes["count"]
)
assert np.allclose(pixels["count"][:], 0)
extra_args = ["--field", "count=8:dtype=float"]
result = _run_cload_pairs(runner, 2, extra_args)
assert result.exit_code == 0
pixels = cooler.Cooler("toy.2.cool").pixels()[:]
assert "count" in pixels.columns and types.is_float_dtype(
pixels.dtypes["count"]
)
assert np.allclose(pixels["count"][:], 0.2)
extra_args = ["--field", "count=8:agg=min,dtype=float"]
result = _run_cload_pairs(runner, 2, extra_args)
assert result.exit_code == 0
pixels = cooler.Cooler("toy.2.cool").pixels()[:]
assert "count" in pixels.columns and types.is_float_dtype(
pixels.dtypes["count"]
)
assert np.allclose(pixels["count"][:], 0.1)
## don't implement the --no-count for now
# extra_args = ['--field', 'score=7:dtype=float', '--no-count']
# result = _run_cload_pairs(runner, 2, extra_args)
# assert result.exit_code == 0
# pixels = cooler.Cooler('toy.2.cool').pixels()[:]
# assert 'count' not in pixels.columns
# assert 'score' in pixels.columns and types.is_float_dtype(pixels.dtypes['score'])
# '--metadata', '',
# '--zero-based',
# '--comment-char', '',
# '--storage-options', '',