Skip to content

[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

Closed
wants to merge 8 commits into from

Conversation

vaibhavhrt
Copy link
Contributor

@vaibhavhrt vaibhavhrt commented Sep 23, 2019

@vaibhavhrt vaibhavhrt changed the title Annotate DataFrame (Part 3) [WIP] Annotate DataFrame (Part 3) Sep 23, 2019
"""
Returns length of info axis, but here we use the index.
"""
return len(self.index)

def dot(self, other):
def dot(self, other: Union[Series, DataFrame]) -> Union[Series, DataFrame]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should include np.ndarray in the signature here. Applicable to the rest below as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright.
Added some types without paying much attention, will take a closer later.
Btw I am guessing if type of other is Series, return type will be Series too, similar for DataFrame and np.ndarray, how do I indicate that.

Copy link
Member

Choose a reason for hiding this comment

The 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 other if the same TypeVar is used for both) but unfortunately I don't think that is how this is actually implemented

Copy link
Contributor Author

@vaibhavhrt vaibhavhrt Sep 24, 2019

Choose a reason for hiding this comment

The 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.

@simonjayhawkins simonjayhawkins added the Typing type annotations, mypy/pyright type checking label Sep 24, 2019
@simonjayhawkins
Copy link
Member

closed as stale. @vaibhavhrt ping if you wish to continue.

@vaibhavhrt
Copy link
Contributor Author

vaibhavhrt commented Oct 21, 2019 via email

@vaibhavhrt vaibhavhrt marked this pull request as ready for review December 2, 2019 07:34
@vaibhavhrt
Copy link
Contributor Author

removing from draft, otherwise I keep forgetting about it. Will try it get it done fast now.

@@ -23,6 +23,7 @@
from pandas.core.indexes.base import Index # noqa: F401
from pandas.core.series import Series # noqa: F401
from pandas.core.generic import NDFrame # noqa: F401
from pandas.io.formats.style import Styler # noqa: F401
Copy link
Member

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

@@ -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]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this required for mypy? If not can you revert?

@jreback
Copy link
Contributor

jreback commented Jan 1, 2020

closing as stale, ping if you want to continue.

@jreback jreback closed this Jan 1, 2020
@stangirala
Copy link
Contributor

@WillAyd are we working on this (and #26792)?

@stangirala
Copy link
Contributor

I can help out here, I really want to see type checking with a df.

@WillAyd
Copy link
Member

WillAyd commented Mar 31, 2020

@stangirala this PR specifically is stale; if you have contributions you'd like to make for that feel free to push a separate PR

@stangirala
Copy link
Contributor

@WillAyd can I use this PR as a template?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants