Skip to content

Inconsistent use of _ to separate words in method names #14278

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

Open
Anaphory opened this issue Sep 22, 2016 · 1 comment
Open

Inconsistent use of _ to separate words in method names #14278

Anaphory opened this issue Sep 22, 2016 · 1 comment
Labels
API - Consistency Internal Consistency of API/Behavior Enhancement Needs Discussion Requires discussion from core team before further action

Comments

@Anaphory
Copy link

Anaphory commented Sep 22, 2016

Sometimes, method names contain underscores to separate words (to_string) and sometimes not (tolist). This catches me of regularly. Particulary annoying are the cases where the same prefix (eg. to) sometimes takes an underscore and sometimes not.

Is this going to change for future major versions?

Example: dir(Index)

  • Without underscore between words, but the compound is well-established: 'argmax', 'argmin', 'argsort', 'nbytes', 'ndim', 'nlevels', 'nunique', 'putmask'
  • Without underscore: 'astype', 'fillna', 'hasnans', 'isin', 'itemsize', 'searchsorted', 'sortlevel', 'tolist'
  • With underscore: 'drop_duplicates', 'get_duplicates', 'get_indexer', 'get_indexer_for', 'get_indexer_non_unique', 'get_level_values', 'get_loc', 'get_slice_bound', 'get_value', 'get_values', 'groupby', 'has_duplicates', 'holds_integer', 'inferred_type', 'is_all_dates', 'is_boolean', 'is_categorical', 'is_floating', 'is_integer', 'is_lexsorted_for_tuple', 'is_mixed', 'is_monotonic', 'is_monotonic_decreasing', 'is_monotonic_increasing', 'is_numeric', 'is_object', 'is_type_compatible', 'is_unique', 'memory_usage', 'set_names', 'set_value', 'slice_indexer', 'slice_locs', 'sort_values', 'sym_diff', 'symmetric_difference', 'to_datetime', 'to_native_types', 'to_series', 'value_counts'
@jreback
Copy link
Contributor

jreback commented Sep 22, 2016

mostly a dupe of #8826

the only ones with any rationale are:

tolist -> to_list (for compat with rest of pandas to_* methods)
hasnans -> hasna (inconsistent naming, e.g. fillna, dropna)

the other are long long established and in particular searchsorted, itemsize, astype are super common numpy references

sortlevel should actually be deprecated as sort_index does all of this.

@jbrockmendel jbrockmendel added the Code Style Code style, linting, code_checks label Jul 23, 2019
@simonjayhawkins simonjayhawkins added Needs Discussion Requires discussion from core team before further action and removed Code Style Code style, linting, code_checks labels Dec 11, 2019
@jbrockmendel jbrockmendel added API - Consistency Internal Consistency of API/Behavior and removed API Design labels Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API - Consistency Internal Consistency of API/Behavior Enhancement Needs Discussion Requires discussion from core team before further action
Projects
None yet
Development

No branches or pull requests

5 participants