Skip to content
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

tab complete lurking groupby methods #4501

Closed
cpcloud opened this issue Aug 7, 2013 · 5 comments · Fixed by #5050
Closed

tab complete lurking groupby methods #4501

cpcloud opened this issue Aug 7, 2013 · 5 comments · Fixed by #5050
Milestone

Comments

@cpcloud
Copy link
Member

cpcloud commented Aug 7, 2013

Would be nice to have tab completion for groupby methods that are "lazily determined" (not sure if that is the correct terminology)

see related issue #4500

see this SO question for an example (also linked to in #4500 )

@jreback
Copy link
Contributor

jreback commented Sep 27, 2013

shouldn't this function definition go in core/base.py and then can be run on individual class/modules as needed?
@cpcloud @jtratner (this is bottom of core/frame.py and others now

def install_ipython_completers():  # pragma: no cover
    """Register the DataFrame type with IPython's tab completion machinery, so
    that it knows about accessing column names as attributes."""
    from IPython.utils.generics import complete_object

    @complete_object.when_type(DataFrame)
    def complete_dataframe(obj, prev_completions):
        return prev_completions + [c for c in obj.columns
                                   if isinstance(c, compat.string_types) and compat.isidentifier(c)]


# Importing IPython brings in about 200 modules, so we want to avoid it unless
# we're in IPython (when those modules are loaded anyway).
if "IPython" in sys.modules:  # pragma: no cover
    try:
        install_ipython_completers()
    except Exception:
        pass

@cpcloud
Copy link
Member Author

cpcloud commented Sep 27, 2013

fyi these would have to be everything on the current whitelist plus whatever attributes there are (which i think is automatically done by ipython)

@ghost ghost assigned jtratner Sep 27, 2013
@jtratner
Copy link
Contributor

Couldn't we just define dir instead? Any reason not to do that?

@jtratner
Copy link
Contributor

Er __dir__ rather

@cpcloud
Copy link
Member Author

cpcloud commented Sep 27, 2013

yep looks like that's the way to do it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants