Skip to content

Commit c32b80b

Browse files
code sample for pandas-dev#38601
1 parent 152659e commit c32b80b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

bisect/38601.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import numpy as np
2+
import pandas as pd
3+
4+
print(pd.__version__)
5+
6+
# create a dataframe with non-lexsorted multilevel columns
7+
df = pd.DataFrame(
8+
np.arange(12).reshape(3, 4),
9+
columns=pd.MultiIndex.from_tuples([("B", 1), ("B", 2), ("A", "3"), ("A", "4")]),
10+
)
11+
12+
df.loc[:, "A"] = np.zeros(
13+
(3, 2)
14+
) # ValueError: Must have equal len keys and value when setting with an ndarray
15+
16+
print(df)

0 commit comments

Comments
 (0)