Skip to content

ENH: option to change the number in _dir_additions_for_owner #44335

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

Merged
merged 18 commits into from
Nov 26, 2021

Conversation

TheDerivator
Copy link
Contributor

@TheDerivator TheDerivator commented Nov 6, 2021

  • closes ENH: raise column number limit for user-completion or add warning #37996
  • tests added / passed
  • Allows to optionally change the number of columns from a dataframe that are added to dir, which is frequently also the number of columns suggested by tab completion, by using the option pandas.set_option('display.max_dir_additions', 100) to a higher number than 100 or None for an unlimited number of columns. Changing the value of display.max_dir_additions will only take effect for existing dataframes after a column is added or deleted, as the result of dir is cached.

@TheDerivator TheDerivator changed the title ENH: option to change the number in __max_dir_additions ENH: option to change the number in _dir_additions_for_owner Nov 6, 2021
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

why are we not just using max_columns for this?

@TheDerivator
Copy link
Contributor Author

TheDerivator commented Nov 7, 2021

why are we not just using max_columns for this?

If you have a dataframe with 10 000 columns you will not want to have them all pretty printed, but you may still want to have all columns suggested by tab completion. (edit: so you need to be able to set them to a different value)

@jreback
Copy link
Contributor

jreback commented Nov 7, 2021

really? you are going to scroll thru them?

i don't really like adding yet another option

if people really want to scroll then just increase the default

@TheDerivator
Copy link
Contributor Author

No you do not scroll thru them. Instead you type the first two (or so) letters and press the tab button. The editor will then suggest names for columns that start with those letters. This is called tab completion. Except that, currently, it will not suggest names of columns that are beyond the first 100 columns since these are not known to dir.

For instance, if you grab a jupyter notebook and take some random data

import string
import pandas as pd
import numpy as np
columns = [u + v for u in string.ascii_lowercase for v in string.ascii_lowercase]
data = np.random.normal(0, 1, (100, len(columns)))
df = pd.DataFrame(data, columns=columns)

then df.e<tab> will not return any suggestions for columns. (It will suggest things like df.eq though, but because this is a method.) With this pull request, if you set pd.set_option('display.max_dir_items', None) then it will suggest ea etc. until ez. However if you were to set at the same time pd.set_option('display.max_columns', None) then df will print all 26 * 26 columns.

@jreback
Copy link
Contributor

jreback commented Nov 7, 2021

i c ok then

need tests
and update the options documentation
and a ehatsnew note

@TheDerivator

This comment has been minimized.

@jreback jreback added the Output-Formatting __repr__ of pandas objects, to_string label Nov 13, 2021
@jreback jreback added this to the 1.4 milestone Nov 17, 2021
@jreback
Copy link
Contributor

jreback commented Nov 17, 2021

cc @pandas-dev/pandas-core and @arw2019 if any comments here.

@jreback jreback merged commit 068b599 into pandas-dev:master Nov 26, 2021
@jreback
Copy link
Contributor

jreback commented Nov 26, 2021

thanks @TheDerivator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH: raise column number limit for user-completion or add warning
3 participants