We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent eab8bee commit 918e89aCopy full SHA for 918e89a
databricks/koalas/base.py
@@ -363,6 +363,39 @@ def is_monotonic_decreasing(self):
363
window = Window.orderBy(monotonically_increasing_id()).rowsBetween(-1, -1)
364
return self._with_new_scol((col <= F.lag(col, 1).over(window)) & col.isNotNull()).all()
365
366
+ @property
367
+ def ndim(self):
368
+ """
369
+ Return an int representing the number of array dimensions.
370
+
371
+ Return 1 for Series / Index / MultiIndex.
372
373
+ Examples
374
+ --------
375
376
+ For Series
377
378
+ >>> s = ks.Series([None, 1, 2, 3, 4], index=[4, 5, 2, 1, 8])
379
+ >>> s.ndim
380
+ 1
381
382
+ For Index
383
384
+ >>> s.index.ndim
385
386
387
+ For MultiIndex
388
389
+ >>> midx = pd.MultiIndex([['lama', 'cow', 'falcon'],
390
+ ... ['speed', 'weight', 'length']],
391
+ ... [[0, 0, 0, 1, 1, 1, 2, 2, 2],
392
+ ... [1, 1, 1, 1, 1, 2, 1, 2, 2]])
393
+ >>> s = ks.Series([45, 200, 1.2, 30, 250, 1.5, 320, 1, 0.3], index=midx)
394
395
396
397
+ return 1
398
399
def astype(self, dtype):
400
"""
401
Cast a Koalas object to a specified dtype ``dtype``.
databricks/koalas/frame.py
@@ -382,7 +382,7 @@ def ndim(self):
Return an int representing the number of array dimensions.
- Return 1 if Series. Otherwise return 2 if DataFrame.
+ return 2 for DataFrame.
Examples
--------
databricks/koalas/indexes.py
@@ -151,27 +151,6 @@ def names(self, names: List[Union[str, Tuple[str, ...]]]) -> None:
151
names = [name if isinstance(name, tuple) else (name,) for name in names]
152
self._kdf._internal = internal.copy(index_map=list(zip(internal.index_columns, names)))
153
154
- @property
155
- def ndim(self):
156
- """
157
- Number of dimensions of the underlying data, by definition 1.
158
-
159
- Examples
160
- --------
161
- >>> s = ks.Series([None, 1, 2, 3, 4], index=[4, 5, 2, 1, 8])
162
- >>> s.index.ndim
163
- 1
164
165
- >>> midx = pd.MultiIndex([['lama', 'cow', 'falcon'],
166
- ... ['speed', 'weight', 'length']],
167
- ... [[0, 0, 0, 1, 1, 1, 2, 2, 2],
168
- ... [1, 1, 1, 1, 1, 2, 1, 2, 2]])
169
- >>> s = ks.Series([45, 200, 1.2, 30, 250, 1.5, 320, 1, 0.3], index=midx)
170
171
172
173
- return 1
174
175
def rename(self, name: Union[str, Tuple[str, ...]], inplace: bool = False):
176
177
Alter Index name.
databricks/koalas/series.py
@@ -821,11 +821,6 @@ def shape(self):
821
"""Return a tuple of the shape of the underlying data."""
822
return len(self),
823
824
825
826
- """Returns number of dimensions of the Series."""
827
828
829
@property
830
def name(self) -> Union[str, Tuple[str, ...]]:
831
"""Return name of the Series."""
0 commit comments