Skip to content
/ cnames Public

function for pandas dataframe column tab completion

License

Notifications You must be signed in to change notification settings

ebenp/cnames

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cnames

cnames generates a namedtuple for pandas dataframe columns. When added to the pandas DataFrame class through monkey patching column names can be obtained through tab completion in interactive mode.

Getting Started

Prerequisites

This module uses namedtuples which were introduced in Python 2.6. Code was developed and tested on Python 3, Pandas 0.18.1 and IPython 5.3.0.

Python >= 2.6
Pandas >= 0.18.1

Installing

Use pip to install via wheel. If you have downloaded the module locally then change to that directory and use pip

pip install cnames-0.1-py2.py3-none-any.whl

You can also install via URL

pip install https://github.com/ebenp/cnames/releases/download/0.1/cnames-0.1-py2.py3-none-any.whl

Running tests

A test dataframe under the main() statement in cnames.py is available for use.

Usage

After import assign cnames to the DataFrame class.

import pandas as pd
from cnames import cnames

# monkey-patch the DataFrame class
pd.DataFrame.cnames = cnames

To use cnames call the function on the desired DataFrame in interactive mode, in IPython or a debugging environment

# tab completetion will populate with
column names along with DataFrame attributes and methods

df.cnames().<tab completion>

In some cases, Jupyter Notebook and default IPython, IPCompleter.greedy needs to be set for cnames to correctly populate.

%config IPCompleter.greedy = True

However, be warned that enabling this option can be unsafe, because the code is actually evaluated upon hitting TAB. This is why the feature is disabled by default. Also, enabling this seems to prevent filepath completion inside of quotes.

Contributing

Please feel free to submit issues or pull requests.

Versioning

For the versions available, see the tags on this repository.

Authors

  • Eben Pendleton - Initial work - ebenp

Modified from a stackoverflow answer. Answer was given by user Maturin. Thanks!

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

About

function for pandas dataframe column tab completion

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages