-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
[WIP] Annotate DataFrame (Part 3) #28575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c642cf7
035d28a
0bbd370
a640588
d1e92f9
cc767b3
fd5ddd5
ca64736
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,7 +84,7 @@ | |
) | ||
from pandas.core.dtypes.missing import isna, notna | ||
|
||
from pandas._typing import Axes, Dtype, FilePathOrBuffer | ||
from pandas._typing import Axes, Dtype, FilePathOrBuffer, Styler | ||
from pandas.core import algorithms, common as com, nanops, ops | ||
from pandas.core.accessor import CachedAccessor | ||
from pandas.core.arrays import Categorical, ExtensionArray | ||
|
@@ -804,7 +804,7 @@ def to_string( | |
# ---------------------------------------------------------------------- | ||
|
||
@property | ||
def style(self): | ||
def style(self) -> "Styler": | ||
vaibhavhrt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
Returns a Styler object. | ||
|
||
|
@@ -882,7 +882,7 @@ def items(self) -> Iterable[Tuple[Optional[Hashable], Series]]: | |
def iteritems(self): | ||
yield from self.items() | ||
|
||
def iterrows(self): | ||
def iterrows(self) -> Iterable[Tuple[Index, Series]]: | ||
""" | ||
Iterate over DataFrame rows as (index, Series) pairs. | ||
|
||
|
@@ -1020,7 +1020,7 @@ def __len__(self) -> int: | |
""" | ||
return len(self.index) | ||
|
||
def dot(self, other): | ||
def dot(self, other: Union[Series, DataFrame]) -> Union[Series, DataFrame]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should include There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A TypeVar would make the function generic (i.e. the return type would match There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, pretty sure saw something like that in the docstring. But did this in a hurry(thats why draft PR), a bit busy. Will take a closer look as soon as I can. |
||
""" | ||
Compute the matrix multiplication between the DataFrame and other. | ||
|
||
|
@@ -1131,13 +1131,13 @@ def dot(self, other): | |
else: # pragma: no cover | ||
raise TypeError("unsupported type: {oth}".format(oth=type(other))) | ||
|
||
def __matmul__(self, other): | ||
def __matmul__(self, other: Union[Series, DataFrame]) -> Union[Series, DataFrame]: | ||
""" | ||
Matrix multiplication using binary `@` operator in Python>=3.5. | ||
""" | ||
return self.dot(other) | ||
|
||
def __rmatmul__(self, other): | ||
def __rmatmul__(self, other: Union[Series, DataFrame]) -> Union[Series, DataFrame]: | ||
""" | ||
Matrix multiplication using binary `@` operator in Python>=3.5. | ||
""" | ||
|
@@ -4631,7 +4631,7 @@ def drop_duplicates(self, subset=None, keep="first", inplace=False): | |
duplicated = self.duplicated(subset, keep=keep) | ||
|
||
if inplace: | ||
(inds,) = (-duplicated)._ndarray_values.nonzero() | ||
inds = (-duplicated)._ndarray_values.nonzero()[0] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this required for mypy? If not can you revert? |
||
new_data = self._data.take(inds) | ||
self._update_inplace(new_data) | ||
else: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just put this in a
if TYPE_CHECKING
block in pandas.core.frame instead of here