s1.is_integer() Out[38]: True In [39]: s2.is_integer() Out[39]: True In [40]: s6.is_integer() Out[40]: False 属性汇总 对Pandas的常用属性进行一下简单的汇总。需要注意的是针对行索引的属性同样适用于列属性columns,英文它们二者都是同属于Pandas中的index对象。发布...
is_integer()检查索引是否仅包含整数。返回: bool 索引是否仅由整数组成。例子:>>> idx = pd.Index([1, 2, 3, 4]) >>> idx.is_integer() True>>> idx = pd.Index([1.0, 2.0, 3.0, 4.0]) >>> idx.is_integer() False>>> idx = pd.Index(["Apple", "Mango", "Watermelon"]) >>> ...
取出所有非整数类型 让我们从第 4 题开始,取出 D 列全部非整数行,其实在 pandas 中可以使用.is_integer() 判断一个元素是否为整数。 这样我们就能结合 apply 函数找到全部整数行 再使用 ~ 取其补集即可得到答案 df[~df[['D']].apply(lambda x: x[0].is_integer(), axis=1)] 取出所有数值类型 第3...
4. pd.api.types.is_integer_dtype:判断是否为整型数据类型。 5. pd.api.types.is_float_dtype:判断是否为浮点型数据类型。 6. pd.api.types.is_numeric_dtype:判断是否为数值型数据类型。 7. pd.api.types.is_datetime64_dtype:判断是否为datetime64类型的日期时间数据类型。 8. pd.api.types.is_timedelt...
not fall back to positional-> 1237 loc = self.index.get_loc(label)1239 if is_integer(loc):1240 return self._values[loc]File ~/work/pandas/pandas/pandas/core/indexes/range.py:415, in RangeIndex.get_loc(self, key)413 return self._range.index(new_key)414 except ValueError as err:-->...
if self.center is not None and not is_bool(self.center): raise ValueError("center must be a boolean") if self.min_periods is not None and not \ is_integer(self.min_periods): raise ValueError("min_periods must be an integer") def _convert_freq(self, how=None): """ resample accord...
is_integer, is_scalar, is_categorical_dtype, is_datetime64_dtype, is_timedelta64_dtype, is_datetime64tz_dtype, _ensure_int64) import pandas.core.algorithms as algos import pandas.core.nanops as nanops from pandas._libs.lib import infer_dtype from pandas import (to_timedelta, to_datetime, ...
(label)1239 if is_integer(loc):1240 return self._values[loc]File ~/work/pandas/pandas/pandas/core/indexes/base.py:3812, in Index.get_loc(self, key)3807 if isinstance(casted_key, slice) or (3808 isinstance(casted_key, abc.Iterable)3809 and any(isinstance(x, slice) for x in casted_...
[ns]', freq=None) # division can result in a Timedelta if the divisor is an integer In [121]: tdi / 2 Out[121]: TimedeltaIndex(['0 days 12:00:00', NaT, '1 days 00:00:00'], dtype='timedelta64[ns]', freq=None) # or a float64 Index if the divisor is a Timedelta In [...
RangeIndex: Index implementing a monotonic integer range Int64Index MultiIndex: A multi-level, or hierarchical, Index DatetimeIndex MultiIndex相对复杂,在GroupBy操作中比较常用。 The MultiIndex object is the hierarchical analogue of the standard Index object which typically stores the axis labels in pandas...