Skip to content

Commit 95f3693

Browse files
committed
DOC: Add note about unicode layout
1 parent 255fa04 commit 95f3693

File tree

6 files changed

+22
-11
lines changed

6 files changed

+22
-11
lines changed
10.5 KB
Loading
7.69 KB
Loading
5.22 KB
Loading
5.35 KB
Loading

doc/source/options.rst

+14-9
Original file line numberDiff line numberDiff line change
@@ -454,42 +454,47 @@ Unicode Formatting
454454
Some East Asian countries use Unicode characters its width is corresponding to 2 alphabets.
455455
If DataFrame or Series contains these characters, default output cannot be aligned properly.
456456

457+
.. note:: Screen captures are attached for each outputs to show the actual results.
458+
457459
.. ipython:: python
458460
459461
df = pd.DataFrame({u'国籍': ['UK', u'日本'], u'名前': ['Alice', u'しのぶ']})
460-
df
462+
df;
463+
464+
.. image:: _static/option_unicode01.png
461465

462466
Enable ``display.unicode.east_asian_width`` allows pandas to check each character's "East Asian Width" property.
463467
These characters can be aligned properly by checking this property, but it takes longer time than standard ``len`` function.
464468

465469
.. ipython:: python
466470
467471
pd.set_option('display.unicode.east_asian_width', True)
468-
df
472+
df;
473+
474+
.. image:: _static/option_unicode02.png
469475

470476
In addition, Unicode contains characters which width is "Ambiguous". These character's width should be either 1 or 2 depending on terminal setting or encoding. Because this cannot be distinguished from Python, ``display.unicode.ambiguous_as_wide`` option is added to handle this.
471477

472478
By default, "Ambiguous" character's width, "¡" (inverted exclamation) in below example, is regarded as 1.
473479

474-
.. note::
475-
476-
This should be aligned properly in terminal which uses monospaced font.
477-
478480
.. ipython:: python
479481
480482
df = pd.DataFrame({'a': ['xxx', u'¡¡'], 'b': ['yyy', u'¡¡']})
481-
df
483+
df;
484+
485+
.. image:: _static/option_unicode03.png
482486

483487
Enabling ``display.unicode.ambiguous_as_wide`` lets pandas to regard these character's width as 2. Note that this option will be effective only when ``display.unicode.east_asian_width`` is enabled. Confirm starting position has been changed, but not aligned properly because the setting is mismatched with this environment.
484488

485489
.. ipython:: python
486490
487491
pd.set_option('display.unicode.ambiguous_as_wide', True)
488-
df
492+
df;
493+
494+
.. image:: _static/option_unicode04.png
489495

490496
.. ipython:: python
491497
:suppress:
492498
493499
pd.set_option('display.unicode.east_asian_width', False)
494500
pd.set_option('display.unicode.ambiguous_as_wide', False)
495-

doc/source/whatsnew/v0.17.0.txt

+8-2
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,16 @@ Some East Asian countries use Unicode characters its width is corresponding to 2
353353
.. ipython:: python
354354

355355
df = pd.DataFrame({u'国籍': ['UK', u'日本'], u'名前': ['Alice', u'しのぶ']})
356-
df
356+
df;
357+
358+
.. image:: _static/option_unicode01.png
359+
360+
.. ipython:: python
357361

358362
pd.set_option('display.unicode.east_asian_width', True)
359-
df
363+
df;
364+
365+
.. image:: _static/option_unicode02.png
360366

361367
For further details, see :ref:`here <options.east_asian_width>`
362368

0 commit comments

Comments
 (0)