Skip to content

Commit 925e5db

Browse files
6th update for issue 3439
1 parent e637369 commit 925e5db

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

pandas/core/reshape/pivot.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -438,27 +438,26 @@ def crosstab(index, columns, values=None, rownames=None, colnames=None,
438438
439439
Examples
440440
--------
441-
>>> a
442-
array([foo, foo, foo, foo, bar, bar,
443-
bar, bar, foo, foo, foo], dtype=object)
444-
>>> b
445-
array([one, one, one, two, one, one,
446-
one, two, two, two, one], dtype=object)
447-
>>> c
448-
array([dull, dull, shiny, dull, dull, shiny,
449-
shiny, dull, shiny, shiny, shiny], dtype=object)
441+
>>> a = np.array(["foo", "foo", "foo", "foo", "bar", "bar",
442+
... "bar", "bar", "foo", "foo", "foo"], dtype=object)
443+
>>> b = np.array(["one", "one", "one", "two", "one", "one",
444+
... "one", "two", "two", "two", "one"], dtype=object)
445+
>>> c = np.array(["dull", "dull", "shiny", "dull", "dull", "shiny",
446+
... "shiny", "dull", "shiny", "shiny", "shiny"],
447+
... dtype=object)
450448
451449
>>> crosstab(a, [b, c], rownames=['a'], colnames=['b', 'c'])
452-
b one two
453-
c dull shiny dull shiny
450+
... # doctest: +NORMALIZE_WHITESPACE
451+
b one two
452+
c dull shiny dull shiny
454453
a
455-
bar 1 2 1 0
456-
foo 2 2 1 2
454+
bar 1 2 1 0
455+
foo 2 2 1 2
457456
458457
>>> foo = pd.Categorical(['a', 'b'], categories=['a', 'b', 'c'])
459458
>>> bar = pd.Categorical(['d', 'e'], categories=['d', 'e', 'f'])
460459
>>> crosstab(foo, bar) # 'c' and 'f' are not represented in the data,
461-
# but they still will be counted in the output
460+
... # but they still will be counted in the output
462461
col_0 d e f
463462
row_0
464463
a 1 0 0

0 commit comments

Comments
 (0)