Skip to content

Instantly share code, notes, and snippets.

@mingderwang
Forked from TomAugspurger/max_info.ipynb
Last active August 19, 2020 06:47
Show Gist options
  • Save mingderwang/258d0c185250ad2bcd147f69a9c27a25 to your computer and use it in GitHub Desktop.
Save mingderwang/258d0c185250ad2bcd147f69a9c27a25 to your computer and use it in GitHub Desktop.
max_info
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"name": "",
"signature": "sha256:a2136a9b764b8cc306e3505c177878f34420d0caedfc615b7f914e5627ef7425"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"df = pd.DataFrame(np.random.randn(10, 3))"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"df"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>0</th>\n",
" <th>1</th>\n",
" <th>2</th>\n",
" <th>3</th>\n",
" <th>4</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>-0.461551</td>\n",
" <td> 0.337281</td>\n",
" <td> 2.386641</td>\n",
" <td>-0.063649</td>\n",
" <td>-1.120149</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>-1.251335</td>\n",
" <td> 1.578450</td>\n",
" <td>-0.342258</td>\n",
" <td> 0.098727</td>\n",
" <td> 0.096191</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>-1.732438</td>\n",
" <td>-1.697958</td>\n",
" <td>-0.159549</td>\n",
" <td>-0.038545</td>\n",
" <td> 0.165542</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td> 1.499082</td>\n",
" <td> 0.939494</td>\n",
" <td>-0.089698</td>\n",
" <td> 0.711280</td>\n",
" <td>-0.747168</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>-0.257008</td>\n",
" <td> 0.849296</td>\n",
" <td>-0.922523</td>\n",
" <td>-0.420108</td>\n",
" <td>-0.522947</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td> 1.133592</td>\n",
" <td> 0.989736</td>\n",
" <td> 0.389640</td>\n",
" <td> 1.245466</td>\n",
" <td>-0.369549</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>-0.481618</td>\n",
" <td> 1.209619</td>\n",
" <td>-0.797668</td>\n",
" <td>-1.085983</td>\n",
" <td>-0.924849</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td> 0.029566</td>\n",
" <td> 1.440946</td>\n",
" <td>-0.273174</td>\n",
" <td>-0.676727</td>\n",
" <td> 0.689995</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td> 0.712432</td>\n",
" <td> 1.021626</td>\n",
" <td> 0.212807</td>\n",
" <td>-0.719138</td>\n",
" <td> 0.548671</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>-0.958496</td>\n",
" <td>-1.494948</td>\n",
" <td> 0.401581</td>\n",
" <td> 0.252721</td>\n",
" <td>-1.507747</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>10 rows \u00d7 5 columns</p>\n",
"</div>"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 2,
"text": [
" 0 1 2 3 4\n",
"0 -0.461551 0.337281 2.386641 -0.063649 -1.120149\n",
"1 -1.251335 1.578450 -0.342258 0.098727 0.096191\n",
"2 -1.732438 -1.697958 -0.159549 -0.038545 0.165542\n",
"3 1.499082 0.939494 -0.089698 0.711280 -0.747168\n",
"4 -0.257008 0.849296 -0.922523 -0.420108 -0.522947\n",
"5 1.133592 0.989736 0.389640 1.245466 -0.369549\n",
"6 -0.481618 1.209619 -0.797668 -1.085983 -0.924849\n",
"7 0.029566 1.440946 -0.273174 -0.676727 0.689995\n",
"8 0.712432 1.021626 0.212807 -0.719138 0.548671\n",
"9 -0.958496 -1.494948 0.401581 0.252721 -1.507747\n",
"\n",
"[10 rows x 5 columns]"
]
}
],
"prompt_number": 2
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"pd.set_option('display.large_repr', 'info',\n",
" 'display.max_info_columns', 4,\n",
" 'display.max_columns', 2)\n"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 3
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"`max_info_columns` exceeded => Truncate unless `verbose=True`"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"df"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<pre><class 'pandas.core.frame.DataFrame'>\n",
"Int64Index: 10 entries, 0 to 9\n",
"Columns: 5 entries, 0 to 4\n",
"dtypes: float64(5)</pre>"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 4,
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"Int64Index: 10 entries, 0 to 9\n",
"Columns: 5 entries, 0 to 4\n",
"dtypes: float64(5)"
]
}
],
"prompt_number": 4
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"df.info()"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"Int64Index: 10 entries, 0 to 9\n",
"Columns: 5 entries, 0 to 4\n",
"dtypes: float64(5)"
]
}
],
"prompt_number": 5
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"df.info(verbose=True)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"Int64Index: 10 entries, 0 to 9\n",
"Data columns (total 5 columns):\n",
"0 10 non-null float64\n",
"1 10 non-null float64\n",
"2 10 non-null float64\n",
"3 10 non-null float64\n",
"4 10 non-null float64\n",
"dtypes: float64(5)"
]
}
],
"prompt_number": 6
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"df.info(verbose=False)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"Int64Index: 10 entries, 0 to 9\n",
"Columns: 5 entries, 0 to 4\n",
"dtypes: float64(5)"
]
}
],
"prompt_number": 7
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"pd.set_option('display.max_info_columns', 5)"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 8
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
"source": [
"`max_info_columns` not exceeded => don't Truncate unless `verbose=True`"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"df"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<pre><class 'pandas.core.frame.DataFrame'>\n",
"Int64Index: 10 entries, 0 to 9\n",
"Data columns (total 5 columns):\n",
"0 10 non-null float64\n",
"1 10 non-null float64\n",
"2 10 non-null float64\n",
"3 10 non-null float64\n",
"4 10 non-null float64\n",
"dtypes: float64(5)</pre>"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 9,
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"Int64Index: 10 entries, 0 to 9\n",
"Data columns (total 5 columns):\n",
"0 10 non-null float64\n",
"1 10 non-null float64\n",
"2 10 non-null float64\n",
"3 10 non-null float64\n",
"4 10 non-null float64\n",
"dtypes: float64(5)"
]
}
],
"prompt_number": 9
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"df.info()"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"Int64Index: 10 entries, 0 to 9\n",
"Data columns (total 5 columns):\n",
"0 10 non-null float64\n",
"1 10 non-null float64\n",
"2 10 non-null float64\n",
"3 10 non-null float64\n",
"4 10 non-null float64\n",
"dtypes: float64(5)"
]
}
],
"prompt_number": 10
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"df.info(verbose=True)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"Int64Index: 10 entries, 0 to 9\n",
"Data columns (total 5 columns):\n",
"0 10 non-null float64\n",
"1 10 non-null float64\n",
"2 10 non-null float64\n",
"3 10 non-null float64\n",
"4 10 non-null float64\n",
"dtypes: float64(5)"
]
}
],
"prompt_number": 11
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"df.info(verbose=False)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"Int64Index: 10 entries, 0 to 9\n",
"Columns: 5 entries, 0 to 4\n",
"dtypes: float64(5)"
]
}
],
"prompt_number": 12
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"df.__repr__?"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 9
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment