Reputation: 467
For example , how to avoid this:
column1 column2
0 [4623,236236,2362,626226, ... 64662626
1 [6363,554644,6346,346363, ... 73473473
2 [9543,543674,9806,134736, ... 67457733
Upvotes: 1
Views: 3513
Reputation: 11473
Set the display.max_colwidth
option to -1
, check set_options doc for details.
pd.set_option('display.max_colwidth', -1)
Sample Code
import random
import pandas as pd
d = { 'column1' : [random.sample(xrange(100), 100) for i in range(3)],
' column2' : [ random.randint(1000000,10000000) for i in range(3)]}
df = pd.DataFrame(d)
Without set_option
>>> df
column2 column1
0 7746029 [63, 11, 86, 52, 48, 37, 47, 2, 25, 44, 72, 45...
1 9747244 [27, 34, 0, 88, 46, 39, 89, 78, 23, 1, 47, 9, ...
2 2387014 [45, 63, 26, 22, 7, 90, 92, 44, 99, 19, 17, 91...
With set_option
>>> pd.set_option('display.max_colwidth', -1)
>>> df
column2 \
0 7746029
1 9747244
2
2387014
column1
0 [63, 11, 86, 52, 48, 37, 47, 2, 25, 44, 72, 45, 36, 14, 31, 55, 21, 0, 93, 74, 30, 91, 6, 20, 54, 41, 40, 38, 79, 46, 73, 42, 97, 64, 81, 10, 77, 69, 3, 78, 70, 85, 84, 66, 4, 9, 50, 59, 98, 58, 22, 57, 18, 90, 95, 35, 12, 34, 99, 80, 1, 7, 87, 82, 33, 39, 68, 83, 27, 28, 76, 23, 17, 8, 92, 32, 5, 19, 62, 15, 65, 49, 53, 61, 43, 94, 13, 29, 89, 26, 24, 88, 71, 16, 96, 51, 67, 75, 60, 56]
1 [27, 34, 0, 88, 46, 39, 89, 78, 23, 1, 47, 9, 14, 70, 95, 44, 17, 30, 40, 82, 92, 58, 6, 3, 72, 52, 74, 84, 54, 67, 69, 97, 75, 90, 4, 24, 93, 94, 15, 43, 38, 73, 81, 22, 99, 64, 56, 33, 50, 83, 20, 80, 79, 57, 26, 32, 60, 2, 8, 49, 87, 10, 62, 85, 65, 11, 7, 16, 77, 45, 31, 91, 71, 28, 48, 13, 42, 86, 51, 41, 19, 59, 21, 18, 76, 66, 55, 12, 98, 36, 68, 53, 37, 96, 35, 5, 25, 29, 61, 63]
2 [45, 63, 26, 22, 7, 90, 92, 44, 99, 19, 17, 91, 57, 47, 88, 39, 9, 23, 59, 33, 94, 93, 66, 43, 11, 24, 18, 58, 97, 53, 15, 98, 29, 34, 48, 80, 40, 10, 87, 41, 49, 52, 86, 95, 0, 65, 3, 81, 84, 74, 61, 21, 20, 67, 8, 51, 55, 38, 69, 60, 27, 62, 72, 6, 4, 50, 46, 56, 82, 35, 2, 77, 68, 54, 89, 70, 75, 85, 16, 79, 32, 78, 31, 1, 42, 73, 12, 28, 30, 76, 37, 5, 83, 13, 64, 96, 14, 71, 25, 36]
>>>
EDIT-1
In order to print column with huge string/list values you may want to add following setting to the code.
pd.set_option('display.max_seq_items', None)
I tried with columns of list values ~10,000 and it print perfectly.
As per documentation
display.max_seq_items : int or None
when pretty-printing a long sequence, no more then max_seq_items will be printed. If items are omitted, they will be denoted by the addition of ”...” to the resulting string.
If set to None, the number of items to be printed is unlimited. [default: 100] [currently: 100]
Upvotes: 3