0

Using pandas 0.24.2.

Doing the following:

>>> import pandas as pd
>>> pd.DataFrame(range(1000))                     

Displays the following:

10    10
11    11
12    12
13    13
14    14
15    15
16    16
17    17
18    18
19    19
20    20
21    21
22    22
23    23
24    24
25    25
26    26
27    27
28    28
29    29
..   ...
970  970
971  971
972  972
973  973
974  974
975  975
976  976
977  977
978  978
979  979
980  980
981  981
982  982
983  983
984  984
985  985
986  986
987  987
988  988
989  989
990  990
991  991
992  992
993  993
994  994
995  995
996  996
997  997
998  998
999  999

[1000 rows x 1 columns]
>>> 

That is, pd outputs too much data and the table doesn't fit on one screen.

I've looked at other similar questions, like: How do I expand the output display to see more columns? but they talk about pd.utils.terminal, which my pandas version doesn't have:

>>> pd.util.terminal
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'pandas.util' has no attribute 'terminal'

The panda docs, as per usual, don't provide any useful information for this.

Two questions:

  1. Why is this happening?
  2. How can I fix this in an automatic fashion? Ideally without having to set

    import pandas as pd pd.set_option('display.max_rows', 500) pd.set_option('display.max_columns', 500) pd.set_option('display.width', 1000)

every single time I run python.

Henry Henrinson
  • 5,203
  • 7
  • 44
  • 76

1 Answers1

-1

1) Deprecation?

Looks like pandas.util.terminal.get_terminal_size() is likely deprecated as it is not available anymore (nor mentioned in the doc).

Although pandas.util uses the same function from shutil if it can help.

2) Python / Ipython startup file

You're looking for a python startup file or an ipython startup file, which will initiate each ipython session with custom settings. More details regarding pandas config are indeed indicated in the doc.

Hope this will help.

FabienP
  • 3,018
  • 1
  • 20
  • 25
  • Thanks for pointing out the typo - it was an issue when I wrote up the question. pd.util.terminal also doesn't exist; I've ammended the question. On the second point, I am using the default python shell, not ipython. – Henry Henrinson Apr 16 '19 at 22:03
  • Just saw the edit regarding the python startup file - looks promising. I'll investigate and revert and accept your answer if I can get it to work. – Henry Henrinson Apr 16 '19 at 22:08
  • Sure, or you could revert now as answer is in the scope of your question, and accept if it works. – FabienP Apr 16 '19 at 22:11
  • @HenryHenrinson does using a startup file fix your issue? – FabienP May 01 '19 at 18:42