Skip to content

Commit 27df1a5

Browse files
committed
Add note for transpose
1 parent ed50a38 commit 27df1a5

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

databricks/koalas/frame.py

+29-1
Original file line numberDiff line numberDiff line change
@@ -4017,6 +4017,25 @@ def dot(self, other: "Series") -> "Series":
40174017
40184018
It can also be called using ``self @ other`` in Python >= 3.5.
40194019
4020+
.. note:: This method is based on an expensive operation due to the nature
4021+
of big data. Internally it needs to generate each row for each value, and
4022+
then group twice - it is a huge operation. To prevent misusage, this method
4023+
has the 'compute.max_rows' default limit of input length, and raises a ValueError.
4024+
4025+
>>> from databricks.koalas.config import option_context
4026+
>>> with option_context(
4027+
... 'compute.max_rows', 1000, "compute.ops_on_diff_frames", True
4028+
... ): # doctest: +NORMALIZE_WHITESPACE
4029+
... kdf = ks.DataFrame({'a': range(1001)})
4030+
... kser = ks.Series([2], index=['a'])
4031+
... kdf.dot(kser)
4032+
Traceback (most recent call last):
4033+
...
4034+
ValueError: Current DataFrame has more then the given limit 1000 rows.
4035+
Please set 'compute.max_rows' by using 'databricks.koalas.config.set_option'
4036+
to retrieve to retrieve more than 1000 rows. Note that, before changing the
4037+
'compute.max_rows', this operation is considerably expensive.
4038+
40204039
Parameters
40214040
----------
40224041
other : Series
@@ -4059,14 +4078,23 @@ def dot(self, other: "Series") -> "Series":
40594078
0 -4
40604079
1 5
40614080
dtype: int64
4062-
4081+
>>> kdf @ kser2
4082+
0 -4
4083+
1 5
4084+
dtype: int64
40634085
>>> reset_option("compute.ops_on_diff_frames")
40644086
"""
40654087
if not isinstance(other, ks.Series):
40664088
raise TypeError("Unsupported type {}".format(type(other).__name__))
40674089
else:
40684090
return cast(ks.Series, other.dot(self.transpose())).rename(None)
40694091

4092+
def __matmul__(self, other):
4093+
"""
4094+
Matrix multiplication using binary `@` operator in Python>=3.5.
4095+
"""
4096+
return self.dot(other)
4097+
40704098
def to_koalas(self, index_col: Optional[Union[str, List[str]]] = None) -> "DataFrame":
40714099
"""
40724100
Converts the existing DataFrame into a Koalas DataFrame.

0 commit comments

Comments
 (0)