Skip to content

Commit f47bd96

Browse files
code sample for pandas-dev#45621
1 parent dbd6d5a commit f47bd96

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

bisect/45621.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# BUG: 1.4.0 does not preserve initially empty Index and appended by loc assignment. #45621
2+
3+
import pandas as pd
4+
5+
print(pd.__version__)
6+
7+
df = pd.DataFrame(columns=["a", "b"]).set_index("a")
8+
print(df.index, id(df.index)) # Index([], dtype='object', name='a') 4644041536
9+
10+
df.loc[0] = {"b": 0}
11+
result = df.index
12+
print(result, id(df.index)) # Int64Index([0], dtype='int64') 4726025904
13+
14+
expected = pd.Index([0], dtype="int64", name="a")
15+
pd.testing.assert_index_equal(result, expected)

0 commit comments

Comments
 (0)