|
22 | 22 | from typing import Any, List, Optional, Tuple, Union
|
23 | 23 |
|
24 | 24 | import pandas as pd
|
25 |
| -from pandas.api.types import is_list_like |
| 25 | +from pandas.api.types import is_list_like, is_interval_dtype, is_bool_dtype, \ |
| 26 | + is_categorical_dtype, is_integer_dtype, is_float_dtype, is_numeric_dtype, is_object_dtype |
| 27 | + |
26 | 28 | from pyspark import sql as spark
|
27 | 29 | from pyspark.sql import functions as F
|
28 | 30 |
|
@@ -239,6 +241,83 @@ def to_series(self, name: Union[str, Tuple[str, ...]] = None) -> Series:
|
239 | 241 | column_index_names=None),
|
240 | 242 | anchor=kdf)
|
241 | 243 |
|
| 244 | + def is_boolean(self): |
| 245 | + """ |
| 246 | + Return if the current index type is a boolean type. |
| 247 | +
|
| 248 | + Examples |
| 249 | + -------- |
| 250 | + >>> ks.DataFrame({'a': [1]}, index=[True]).index.is_boolean() |
| 251 | + True |
| 252 | + """ |
| 253 | + return is_bool_dtype(self.dtype) |
| 254 | + |
| 255 | + def is_categorical(self): |
| 256 | + """ |
| 257 | + Return if the current index type is a categorical type. |
| 258 | +
|
| 259 | + Examples |
| 260 | + -------- |
| 261 | + >>> ks.DataFrame({'a': [1]}, index=[1]).index.is_categorical() |
| 262 | + False |
| 263 | + """ |
| 264 | + return is_categorical_dtype(self.dtype) |
| 265 | + |
| 266 | + def is_floating(self): |
| 267 | + """ |
| 268 | + Return if the current index type is a floating type. |
| 269 | +
|
| 270 | + Examples |
| 271 | + -------- |
| 272 | + >>> ks.DataFrame({'a': [1]}, index=[1]).index.is_floating() |
| 273 | + False |
| 274 | + """ |
| 275 | + return is_float_dtype(self.dtype) |
| 276 | + |
| 277 | + def is_integer(self): |
| 278 | + """ |
| 279 | + Return if the current index type is a integer type. |
| 280 | +
|
| 281 | + Examples |
| 282 | + -------- |
| 283 | + >>> ks.DataFrame({'a': [1]}, index=[1]).index.is_integer() |
| 284 | + True |
| 285 | + """ |
| 286 | + return is_integer_dtype(self.dtype) |
| 287 | + |
| 288 | + def is_interval(self): |
| 289 | + """ |
| 290 | + Return if the current index type is an interval type. |
| 291 | +
|
| 292 | + Examples |
| 293 | + -------- |
| 294 | + >>> ks.DataFrame({'a': [1]}, index=[1]).index.is_interval() |
| 295 | + False |
| 296 | + """ |
| 297 | + return is_interval_dtype(self.dtype) |
| 298 | + |
| 299 | + def is_numeric(self): |
| 300 | + """ |
| 301 | + Return if the current index type is a numeric type. |
| 302 | +
|
| 303 | + Examples |
| 304 | + -------- |
| 305 | + >>> ks.DataFrame({'a': [1]}, index=[1]).index.is_numeric() |
| 306 | + True |
| 307 | + """ |
| 308 | + return is_numeric_dtype(self.dtype) |
| 309 | + |
| 310 | + def is_object(self): |
| 311 | + """ |
| 312 | + Return if the current index type is a object type. |
| 313 | +
|
| 314 | + Examples |
| 315 | + -------- |
| 316 | + >>> ks.DataFrame({'a': [1]}, index=["a"]).index.is_object() |
| 317 | + True |
| 318 | + """ |
| 319 | + return is_object_dtype(self.dtype) |
| 320 | + |
242 | 321 | def __getattr__(self, item: str) -> Any:
|
243 | 322 | if hasattr(_MissingPandasLikeIndex, item):
|
244 | 323 | property_or_func = getattr(_MissingPandasLikeIndex, item)
|
|
0 commit comments