@@ -169,8 +169,8 @@ class Series(base.IndexOpsMixin, generic.NDFrame):
169
169
Values must be hashable and have the same length as `data`.
170
170
Non-unique index values are allowed. Will default to
171
171
RangeIndex (0, 1, 2, ..., n) if not provided. If data is dict-like
172
- and index is None, then the values in the index are used to
173
- reindex the Series after it is created using the keys in the data .
172
+ and index is None, then the keys in the data are used as the index. If the
173
+ index is not None, the resulting Series is reindexed with the index values .
174
174
dtype : str, numpy.dtype, or ExtensionDtype, optional
175
175
Data type for the output Series. If not specified, this will be
176
176
inferred from `data`.
@@ -179,6 +179,33 @@ class Series(base.IndexOpsMixin, generic.NDFrame):
179
179
The name to give to the Series.
180
180
copy : bool, default False
181
181
Copy input data.
182
+
183
+ Examples
184
+ --------
185
+ Constructing Series from a dictionary with an Index specified
186
+
187
+ >>> d = {'a': 1, 'b': 2, 'c': 3}
188
+ >>> ser = pd.Series(data=d, index=['a', 'b', 'c'])
189
+ >>> ser
190
+ a 1
191
+ b 2
192
+ c 3
193
+ dtype: int64
194
+
195
+ The keys of the dictionary match with the Index values, hence the Index
196
+ values have no effect.
197
+
198
+ >>> d = {'a': 1, 'b': 2, 'c': 3}
199
+ >>> ser = pd.Series(data=d, index=['x', 'y', 'z'])
200
+ >>> ser
201
+ x NaN
202
+ y NaN
203
+ z NaN
204
+ dtype: float64
205
+
206
+ Note that the Index is first build with the keys from the dictionary.
207
+ After this the Series is reindexed with the given Index values, hence we
208
+ get all NaN as a result.
182
209
"""
183
210
184
211
_typ = "series"
0 commit comments