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