Skip to content

Commit eb9db3c

Browse files
committed
ignored example
1 parent ed3b173 commit eb9db3c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

doc/source/user_guide/indexing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1778,7 +1778,7 @@ Examples:
17781778
#If you want positional assignment instead of index alignment:
17791779
# Convert Series to array/list for positional assignment
17801780
1781-
df['positional'] = s1.values # or s1.tolist()
1781+
df['positional'] = s1.tolist()
17821782
17831783
# Or reset the Series index to match DataFrame index
17841784
df['s1_values'] = s1.reindex(df.index)

pandas/core/frame.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4285,6 +4285,18 @@ def __setitem__(self, key, value) -> None:
42854285
b 2 100
42864286
c 3 NaN
42874287
d 4 200
4288+
4289+
Series index labels NOT in DataFrame, ignored:
4290+
4291+
>>> df = pd.DataFrame({"A": [1, 2, 3]}, index=["x", "y", "z"])
4292+
>>> s = pd.Series([10, 20, 30, 40, 50], index=["x", "y", "a", "b", "z"])
4293+
>>> df["B"] = s
4294+
>>> df
4295+
A B
4296+
x 1 10
4297+
y 2 20
4298+
z 3 50
4299+
# Values for 'a' and 'b' are completely ignored!
42884300
"""
42894301
if not PYPY:
42904302
if sys.getrefcount(self) <= 3:

0 commit comments

Comments
 (0)