Skip to content

Commit 67faf6c

Browse files
jorisvandenbosschejreback
authored andcommitted
DOC: fix warnings in whatsnew about MI.labels -> codes rename (#24150)
1 parent 0a5e747 commit 67faf6c

File tree

2 files changed

+54
-18
lines changed

2 files changed

+54
-18
lines changed

doc/source/whatsnew/v0.10.1.rst

+52-16
Original file line numberDiff line numberDiff line change
@@ -97,22 +97,58 @@ columns, this is equivalent to passing a
9797
9898
``HDFStore`` now serializes MultiIndex dataframes when appending tables.
9999

100-
.. ipython:: python
101-
102-
index = MultiIndex(levels=[['foo', 'bar', 'baz', 'qux'],
103-
['one', 'two', 'three']],
104-
labels=[[0, 0, 0, 1, 1, 2, 2, 3, 3, 3],
105-
[0, 1, 2, 0, 1, 1, 2, 0, 1, 2]],
106-
names=['foo', 'bar'])
107-
df = DataFrame(np.random.randn(10, 3), index=index,
108-
columns=['A', 'B', 'C'])
109-
df
110-
111-
store.append('mi',df)
112-
store.select('mi')
113-
114-
# the levels are automatically included as data columns
115-
store.select('mi', "foo='bar'")
100+
.. code-block:: ipython
101+
102+
In [19]: index = MultiIndex(levels=[['foo', 'bar', 'baz', 'qux'],
103+
....: ['one', 'two', 'three']],
104+
....: labels=[[0, 0, 0, 1, 1, 2, 2, 3, 3, 3],
105+
....: [0, 1, 2, 0, 1, 1, 2, 0, 1, 2]],
106+
....: names=['foo', 'bar'])
107+
....:
108+
109+
In [20]: df = DataFrame(np.random.randn(10, 3), index=index,
110+
....: columns=['A', 'B', 'C'])
111+
....:
112+
113+
In [21]: df
114+
Out[21]:
115+
A B C
116+
foo bar
117+
foo one -0.116619 0.295575 -1.047704
118+
two 1.640556 1.905836 2.772115
119+
three 0.088787 -1.144197 -0.633372
120+
bar one 0.925372 -0.006438 -0.820408
121+
two -0.600874 -1.039266 0.824758
122+
baz two -0.824095 -0.337730 -0.927764
123+
three -0.840123 0.248505 -0.109250
124+
qux one 0.431977 -0.460710 0.336505
125+
two -3.207595 -1.535854 0.409769
126+
three -0.673145 -0.741113 -0.110891
127+
128+
In [22]: store.append('mi',df)
129+
130+
In [23]: store.select('mi')
131+
Out[23]:
132+
A B C
133+
foo bar
134+
foo one -0.116619 0.295575 -1.047704
135+
two 1.640556 1.905836 2.772115
136+
three 0.088787 -1.144197 -0.633372
137+
bar one 0.925372 -0.006438 -0.820408
138+
two -0.600874 -1.039266 0.824758
139+
baz two -0.824095 -0.337730 -0.927764
140+
three -0.840123 0.248505 -0.109250
141+
qux one 0.431977 -0.460710 0.336505
142+
two -3.207595 -1.535854 0.409769
143+
three -0.673145 -0.741113 -0.110891
144+
145+
# the levels are automatically included as data columns
146+
In [24]: store.select('mi', "foo='bar'")
147+
Out[24]:
148+
A B C
149+
foo bar
150+
bar one 0.925372 -0.006438 -0.820408
151+
two -0.600874 -1.039266 0.824758
116152
117153
Multi-table creation via ``append_to_multiple`` and selection via
118154
``select_as_multiple`` can create/select from multiple tables and return a

doc/source/whatsnew/v0.20.0.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -899,8 +899,8 @@ doesn't behave as desired.
899899
900900
df = pd.DataFrame(
901901
{'value': [1, 2, 3, 4]},
902-
index=pd.MultiIndex(levels=[['a', 'b'], ['bb', 'aa']],
903-
labels=[[0, 0, 1, 1], [0, 1, 0, 1]]))
902+
index=pd.MultiIndex([['a', 'b'], ['bb', 'aa']],
903+
[[0, 0, 1, 1], [0, 1, 0, 1]]))
904904
df
905905
906906
Previous Behavior:

0 commit comments

Comments
 (0)