本文整理匯總了Python中pandas._libs.lib.is_float方法的典型用法代碼示例。如果您正苦於以下問題:Python lib.is_float方法的具體用法?Python lib.is_float怎麽用?Python lib.is_float使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pandas._libs.lib
的用法示例。
在下文中一共展示了lib.is_float方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: validate_periods
# 需要導入模塊: from pandas._libs import lib [as 別名]
# 或者: from pandas._libs.lib import is_float [as 別名]
def validate_periods(periods):
"""
If a `periods` argument is passed to the Datetime/Timedelta Array/Index
constructor, cast it to an integer.
Parameters
----------
periods : None, float, int
Returns
-------
periods : None or int
Raises
------
TypeError
if periods is None, float, or int
"""
if periods is not None:
if lib.is_float(periods):
periods = int(periods)
elif not lib.is_integer(periods):
raise TypeError('periods must be a number, got {periods}'
.format(periods=periods))
return periods
示例2: cast_scalar_indexer
# 需要導入模塊: from pandas._libs import lib [as 別名]
# 或者: from pandas._libs.lib import is_float [as 別名]
def cast_scalar_indexer(val):
"""
To avoid numpy DeprecationWarnings, cast float to integer where valid.
Parameters
----------
val : scalar
Returns
-------
outval : scalar
"""
# assumes lib.is_scalar(val)
if lib.is_float(val) and val == int(val):
return int(val)
return val